views:

846

answers:

2

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 for 'isScorm' C:\inetpub\wwwroot\Models\Assets1.designer.cs 3459 15 mvc
Error   345 The type 'mvc.Models.Bundle' already contains a definition for 'scormPath' C:\inetpub\wwwroot\Models\Assets1.designer.cs 3480 17 mvc
Error   346 The type 'mvc.Models.Bundle' already contains a definition for 'CompanyID' C:\inetpub\wwwroot\Models\Assets1.designer.cs 3501 14 mvc
...
+5  A: 

Yes, if you keep them in the same namespace this would occurr.

Robban
that was it, thanks
shogun
A: 

OK, I came across this same error when adding another Linq-to-SQL .dbml.

The more specific cause is that you can not have 2 separate .DBML's in the same namespace which reference the same table and column.

Unlike in Datasets, wherein you can have 2 separate Datasets (Dataset1.xsd and Dataset2.xsd) weach ith the same table and same columns, not so in Linq.

DataClass1.dbml with table MyTable with a column myColumn and DataClass2.dbml with table also name MyTable with a column myColumn will fail because myColumn is defined in both designer.cs files within the same namespace.

My workaround: I 'renamed' DataClass2.dbml's MyTable to MyTable_2 and myColumn to myColumn_2.

I then cursed Microsoft, deleted DataClass2.dbml and integrated the 3rd table I needed into DataClass1.dbml, along with other tables (to avoid this issue). DataClass1.dbml now has some 40 tables in it, which now causes the DataClass1.designer.cs file to have over 20,000 lines of 'auto-generated' code.

Lovely, eh.

TechStuffBC