I am using MVC 4, .net 4, and Entity Framework 6. My projects are building on my dev machine which has Visual Studio 2010 installed but on my build server I get a namespace conflict...
The type 'System.ComponentModel.DataAnnotations.Schema.DatabaseGeneratedAttribute' exists in both 'd:\Projects\tools\Apps\LAMS\packages\EntityFramework.6.0.2\lib\net40\EntityFramework.dll' and 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll'
I'm unsure how to resolve this conflict and I do not understand why I do not receive the conflict on my dev machine.
Many thanks
Problem
.NET 4.0 really shouldn't include
System.ComponentModel.DataAnnotations.Schema
so it's a little baffling that you'd get a reference conflict, but apparently .NET 4.5 overwrites 4.0 assemblies.You can find more information in this post by Marc Gravell which states:
Solution
On your development machine, Visual Studio adds a different folder that is used for referencing .NET 4.0 assemblies, which is something like
You can copy that folder over to your build machine, and it should work since MSBuild will reference these when building a project targeting 4.0.
On the other hand, since you have uninstalled .NET 4.5 on your build machine, maybe just reinstalling .NET 4.0 would work as well.
Also, see this Stack Overflow answer.