.NET 4.0 DataAnnotations GAC/EntityFramework冲突

Ale*_*nko 6 .net asp.net gac .net-4.0 entity-framework-6

我正在尝试使用Entity Framework 6为Microsoft .NET 4.0构建一个ASP.NET网站.该网站明确针对.NET 4.0 web.config:

<compilation debug="true" targetFramework="4.0">

,IIS Express的应用程序池applicationhost.config也针对.NET 4.0:

<add name="Clr4ClassicAppPool" managedRuntimeVersion="v4.0" managedPipelineMode="Classic" CLRConfigFile="%IIS_USER_HOME%\config\aspnet.config" autoStart="true" />

启动站点时,会显示许多CS0433编译器错误,如下所示:

error CS0433: The type "System.ComponentModel.DataAnnotations.Schema.TableAttribute" exists in both "c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ComponentModel.DataAnnotations\v4.0_4.0.0.0__31bf3856ad364e35\System.ComponentModel.DataAnnotations.dll" and "c:\Users\%username%\AppData\Local\Temp\Temporary ASP.NET Files\vs\e798ee36\2b3f5a24\assembly\dl3\fd34a92a\0052703a_0990d101\EntityFramework.DLL"

至于我记得,应该是没有System.ComponentModel.DataAnnotations装配在.NET 4.0中,或者至少是它不应该包含类,如TableAttribute,KeyAttribute等我唯一的铅是错误页面,它说的底线

Microsoft .NET Framework, version:4.0.30319; ASP.NET, version:4.6.1055.0
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何为网站专门更改ASP.NET版本(当然,如果这是问题的来源).

小智 0

您是否尝试过将编译批处理设置为 false?

<compilation debug="false" batch="false">
Run Code Online (Sandbox Code Playgroud)