5

I've converted an ASP.net MVC 4 project from .NET 4.0 to .NET 4.5 following the technique outlined in this SO answer -- in particular in the vbproj file I've set TargetFramework to v4.5 and Prefer32Bit to false.

I now get the following error in the Entity Framework model (inherited from the MVC template project)

TableAttribute is ambiguous in the namespace
System.ComponentModel.DataAnnotations.Schema

Using Object Explorer I've seen that TableAttribute in present in assemblies System.ComponentModel.DataAnnotations.dll (taken from the reference assemblies) and EntityFramework.dll (taken from Entity Framework 5 installed from NuGet).

Community
  • 1
  • 1
edymtt
  • 1,778
  • 1
  • 21
  • 37

3 Answers3

12

Browsing through similar SO threads I've understood that, since I've done a manual conversion, the reference of EntityFramework.dll was not updated to point to the (correct) .NET 4.5 assembly.

I removed and re-added the Nuget package and the project compiles -- now TableAttribute is present only in System.ComponentModel.DataAnnotations.dll.

Community
  • 1
  • 1
edymtt
  • 1,778
  • 1
  • 21
  • 37
  • Man wouldn't it be nice if we didn't have to lose hours to the stupidity of the tooling. NuGet is such a POS sometimes. – TombMedia May 07 '15 at 22:13
2

if you're using NPM (Nuget Package Manager) then issue the command:

update-package EntityFramework

Rebuild the project if the error still persist and it will be fixed. This is how I got to fix it.

Thanks!

Sunny Sharma
  • 4,688
  • 5
  • 35
  • 73
1

I have same issue and I only removed the entity framework reference from framework 4.0 folder and added again from framework 4.5 folder in packages under solution

Qazi
  • 66
  • 3