Question

So, with my edmx (MyDatabase.Edmx) file, whenever I update model from database and I rebuild the project, it creates a duplicate designer file (MyDatabase1.Designer.cs). Was wondering if anyone knows of a config file to avoid creating the duplicate file? It happens on my local for dev purposes, my other teammates doesn't get the same issue.

Was it helpful?

Solution 3

So the way I did it is to check out the edmx files from TFS and then refreshed the tables. Rebuild the the project and then rebuild teh solution. For some reason it stopped duplicating the file.

OTHER TIPS

I know this is an old question but I was facing the same problem and found how to resolve it properly. If you look inside the project file containing your .edmx file (so open the .csproj file in any text editor) you'll see many occurrences of the .Designer.cs file name (MyDatabase1.Designer.cs in your case). Change them to MyDatabase.Designer.cs and rename MyDatabase1.Designer.cs file to MyDatabase.Designer.cs to fix the problem.

Looks like you have MyDatabase.Designer.cs included in your project as a regular source file. Just exclude it, delete MyDatabase1.Designer.cs and rebuild the project.

The following question/answers provide good detail on the issue at hand. I stumbled across this answer as I was facing the same issue.

Why is the designer creating two .Designer.cs files when updating model from database?

In a nutshell you need to adjust your .csproj file via an xml editor and adjusting any node (2 to 3) by editing the new file name (i.e. MyDatabase1.Designer.cs) back to MyDatabase.Designer.cs

just remove this lines from .CSproj file:

<Compile Include="Models\Model2.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Model.edmx</DependentUpon>
</Compile>

and then replace Model2.Designer to Model.Designer in same file

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top