350+ errors: does type "blah.blah.blah" already contain a definition?

What does it 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 ... 
+4
source share
2 answers

Yes, if you save them in the same namespace, this will happen.

+7
source

OK, I encountered the same error when adding another LINQ to SQL.dbml.

A more specific reason is that you cannot have 2 separate .DBML in the same namespace that reference the same table and column.

Unlike datasets, in which you can have two separate datasets ( Dataset1.xsd and Dataset2.xsd ) with the same table and the same columns, and not in Linq.

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

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

Then I cursed Microsoft, deleted DataClass2.dbml and integrated the 3rd table that I need into DataClass1.dbml , as well as other tables (to avoid this problem). DataClass1.dbml now contains about 40 tables, which now leads to the fact that the DataClass1.designer.cs file has more than 20,000 lines of code with automatic generation.

Lovely, eh.

+2
source

All Articles