Entity framework 将EF 5与.net 4.0(MVC 4)一起使用时出现无效的方案问题
我有一个我们在MVC4和EntityFramework5.0中开发的web应用程序,它使用.NET4.5运行良好。 然后,因为客户端托管不支持.NET4.5,我需要将所有内容降级到.NET4.0。我犯了个错误Entity framework 将EF 5与.net 4.0(MVC 4)一起使用时出现无效的方案问题,entity-framework,.net-4.0,asp.net-mvc-4,Entity Framework,.net 4.0,Asp.net Mvc 4,我有一个我们在MVC4和EntityFramework5.0中开发的web应用程序,它使用.NET4.5运行良好。 然后,因为客户端托管不支持.NET4.5,我需要将所有内容降级到.NET4.0。我犯了个错误 Could not load System.Net.Http library or one of its dependencies 直到我创建了全新的解决方案和项目,这些解决方案和项目都以.NET4.0为目标,并使用NuGet重新安装了所有必需的软件包 现在,本地的一切都很正常,但是当
Could not load System.Net.Http library or one of its dependencies
直到我创建了全新的解决方案和项目,这些解决方案和项目都以.NET4.0为目标,并使用NuGet重新安装了所有必需的软件包
现在,本地的一切都很正常,但是当我部署到服务器时,我得到了以下错误
Schema specified is not valid. Errors:
(0,0) : warning 0005: Could not find schema information for the attribute 'Namespace'.
(0,0) : warning 0005: Could not find schema information for the attribute 'Provider'.
(0,0) : warning 0005: Could not find schema information for the attribute 'ProviderManifestToken'.
(0,0) : warning 0005: Could not find schema information for the attribute 'Alias'.
(0,0) : error 0010: The element Schema in namespace http://schemas.microsoft.com/ado/2009/11/edm/ssdl was unexpected for the root element. The expected Schema in one of the following namespaces: http://schemas.microsoft.com/ado/2006/04/edm/ssdl, http://schemas.microsoft.com/ado/2009/02/edm/ssdl.
现在我已经确定我使用的所有库都是针对.NET4.0的。NuGet一直在安装EF 5.0,但是库的版本读(4.4),这是我读到的,在.NET4.0中应该可以
我不知道我哪里出了问题,但这真的令人沮丧,任何帮助都将不胜感激。我们首先使用EF4.4代码(DbContext和
此外,不确定这是否会产生影响,我们正在使用CustomMembershipProvider,并且它在本地运行良好,我们目前仅将其用于身份验证。为了避免这个问题,我将其配置从Web.Config中删除,但仍然存在相同的问题。我发现问题出在两个方面:
Database.SetInitializer(新的DropCreateDatabaseIfModelChanges());
以下
Database.SetInitializer(null);
您将在Global.asax.cs中找到这一行
实际上,这一行导致EF检查数据库并确保它与我的模型同步,所以我只需要将我在本地生成的一个数据库恢复到服务器上,然后运行它,一切都很顺利。
希望这能帮助别人