Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linq to SQL creating duplicate designer files

Tags:

c#

linq-to-sql

I have a strange bug with my Linq to SQL DBML files, when ever I save it, instead of saving to the existing designer file a duplicate file is created.

This is causing errors all over the place as there is ambiguity between the data context constructor inside of file.designer.cs and file1.designer.cs

Is there any way to fix this error that doesnt involve deleting and recreating the dmbl files. as this error is happening on all of my DBML files some of which are rather large.

enter image description here

The above image shows the issue that I'm having.

like image 887
Midimatt Avatar asked Oct 19 '11 10:10

Midimatt


2 Answers

Not sure what could have caused this (but Marc's suggestion about the file being readonly or not checked out seems possible), but the association is described in the .proj file. If you open that file with a text editor you should see somewhere within something like:

<ItemGroup>
<None Include="Minerva.dbml">
  <Generator>MSLinqToSQLGenerator</Generator>
  <LastGenOutput>Minerva1.designer.cs</LastGenOutput>
  <SubType>Designer</SubType>
</None>

Replace Minerva1.designer.cs with Minerva.designer.cs. You can now delete or exclude the Minerva1.designer.cs file from you project and the next time the generator is invoked it will overwrite Minerva.designer.cs as expected.

like image 144
saus Avatar answered Oct 02 '22 23:10

saus


I had the same issue. It turns out version control was holding the file. The build process cannot recreate the file so it creates a new one. Since this file is automatically generated, it is safe to remove from the version control. I am using git for my version control.

like image 33
Latheesan Sivarasathurai Avatar answered Oct 02 '22 23:10

Latheesan Sivarasathurai