dbml

350+ errors: The type 'blah.blah.blah' already contains a definition??

What the hell does this mean. Is it because I have two different .DBML files that contain the same database table? ... Error 343 The type 'mvc.Models.Bundle' already contains a definition for 'BundleIcon' C:\inetpub\wwwroot\Models\Assets1.designer.cs 3438 17 mvc Error 344 The type 'mvc.Models.Bundle' already contains a definition fo...

Linq to SQL: Multi-table join return type not generated by dbml

Hello, I'm trying to figure out the best way to handle a simple problem: I have a simple LINQ join to two tables. I know how to return the type for one table, since it is the same as the generated dbml class. However, what if I want to return data from both tables- isn't there a way to return both and use their relationships? Do I rea...

LINQ2SQL: If I make changes to DB, how to mirror them in DBML?

Hi, I am using LINQ2SQL in my current project. I have a quite a lot of tables ~30. When I create my DBML file I change some of the column names etc for readability. Recently if I made a change to the table in the underlying Database I just deleted and re-added the table in the DBML file, but this is getting tedious. How can I mimic ...

[Linq to SQL] Multiple foreign keys to the same table

I have a reference table with all sorts of controlled value lookup data for gender, address type, contact type, etc. Many tables have multiple foreign keys to this reference table I also have many-to-many association tables that have two foreign keys to the same table. Unfortunately, when these tables are pulled into a Linq model and th...

DBML removes .Name Attributes??

I have been renaming our model names in our codebase using resharper. I had made some changes some of the modals names within the .dbml file. I noticed that I need to add the name attribute to the propery in order for the sql to work correctly. I add added this in the code behind view of the .dbml file. I switched back to the designer an...

modifying Linq-to-SQL connection in dbml?

Am I understanding correctly, and the database connection string for Linq to SQL is typically stored in the app.config file, in the connectionStrings section? Are there other places it might be done, typically? Thanks! ...

Property is in intellisense, but still doesn't compile

I renamed one field in the database and added another. Then I removed the table from the DBML file, and re-added it. The I went to access the renamed property. The field shows up in intellisense, but will not compile, throwing a "no definition" error. I removed the project, reset the references, erased all the dlls, rebooted the machine,...

Generation custom files from dbml file?

Hi, I've been having a look at making changes to the partial classes generated from a DBML file. I was reading into using the sqlmetal.exe tool but it appears that you can't do much customisation of what it actually spits out. I'm wanting to make changes to the file for serialization purposes, I'd like to add the Data Member Attribute...

Read DBML xml with LINQ to SQL

Hi All, I want to iterate through the tables in a dbml's xml. But i'm struggling to get to the Type elements. How would I do it using LINQ to SQL? ...

LINQ to SQL DBML Semantic Model

I'm planning to write an tool which would import dbml file and spit out an MDL file for migration purposes and such. To do this, I obviously have to read this dbml file into some kind of semantic model to do transformations. I tried to use XmlMappingSource, but first it failed because it expects the XML namespace of a file to be http:/...

ASP.Net MVC: Best Practices for dbml files...

This may just be a yes or no type of question but here goes anyway... From all (well most) of the examples that I've seen for using mvc, it appears that method for creating the dbml file is just drop the entire schema of the database into it and let it autogenerate all of the linq to sql goodness. It appears that you just need one of t...

How to read Dbml file and map it into an object model in .net?

Im planning to write a code generator to generate UI (forms, grids, etc.). Since i'm using Linq i'm planning to read dbml file for metadata extraction purposes. I wonder if there is some Api to read the Dbml object model (database, tables, columns, asociations). I've opened SQLMetal.exe with Red Gate's .NET Reflector, it contains a nam...

Linq2Sql FROM XSD

I have a scenario where I define the XSD first, then generate the cs files from these XSD (using xsd.exe). I need to take this 2 steps furthur by generating the dbml from these and then calling CreateDatabase() on that dbml). So the question is, does anyone have an idea how to create dbml from either an XSD or a cs file? Thanks Ash ...

Linq DBML Mapping a Table With A Primary Key That Spans 2 Columns

I have three tables: Login, LoginRoles and Roles. Login joins to LoginRoles and LoginRoles joins to Roles. LoginRoles is a many-to-many table, and I want to constrain the columns as being unique TOGETHER. LoginRoles: MemberId (int), RoleId(int) This is similar to the aspnet_UsersInRoles table in the default membership database: Tabl...

Performance of storing DBML generated objects as a LIST<X> in Session

I'm creating an app that will have a fair amount of users. Everytime someone views a page or performs an activity I will be writing to a log. While I'm concerned about the performance of that in itself, my bigger concern is that I'm actually wanting to store that history in-session within the ASP.NET MVC application so that when they l...

LINQ-to-SQL References to Entities in other DataContexts

In my database designs, I tend to have "clusters" of tables. These clusters will typically support one application or group of tightly-functionally-related applications. Often, these clusters also relate to each other through a relatively small number of foreign keys; this helps otherwise independent applications in the business integrat...

Linq to SQL with table name ending in "es" creates wrong entity class name

My SQL tables names are all plural - Events, Teams, Campuses, etc... When I drag the tables in to the dbml, it creates an entity called "Campuse" which of course is incorrect. I manually rename that to Campus in the properties page, but it doesnt seem to update all of the auto generated code correctly. For example, the .designer.cs fil...

Where clause variable for linqtosql from IDs in Stored Procedures.

Hi, I have created a function that retrieves values based on datepart of a datefield from a stored procedure: public List<spDB1GetIDsByTimeResult> GetIDsByTime(int timePart) { using (DB1DataContext db1= new DB1DataContext ()) { List<spDB1GetIDsByTimeResult> query = db1.spDBGetIDsByTime(timePart).ToList()...

dbml with connectionstring

how to generate a DBML file using the ConnectionString in ASP.NET MVC ...

linq to sql strange float behaviour

Hello, I have a problem with a double (TaxRate here), that do not have the same value when it pass through functions: I first call a function DataContext.UpdateCategory(theCategorie.Code, theCategorie.Description, theCategorie.TaxRate, theCategorie.TaxCode); When I run the debugger the value of TaxRate is 19.6 Then when I put a stop...