Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TableAttribute is ambiguous in the namespace System.ComponentModel.DataAnnotations.Schema after conversion to .NET 4.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).

like image 420
edymtt Avatar asked Jul 15 '13 17:07

edymtt


3 Answers

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.

like image 141
edymtt Avatar answered Nov 09 '22 21:11

edymtt


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!

like image 32
Sunny Sharma Avatar answered Nov 09 '22 23:11

Sunny Sharma


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

like image 1
Qazi Avatar answered Nov 09 '22 21:11

Qazi