我正在尝试使用Entity Framework 6为Microsoft .NET 4.0构建ASP.NET网站。该网站在
web.config
中明确地针对.NET 4.0进行了设置:<compilation debug="true" targetFramework="4.0">
。在applicationhost.config
中,IIS Express的应用程序池也将目标设置为.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"
。就我所知,在.NET 4.0中不应存在System.ComponentModel.DataAnnotations
程序集,或者至少不应包含像TableAttribute
、KeyAttribute
等类。我唯一的线索是错误页面的最后一行,它说:Microsoft .NET Framework, version:4.0.30319; ASP.NET, version:4.6.1055.0
然而,我不知道如何为网站专门更改ASP.NET版本(当然,如果这是问题的根源)。