[英]Support SQL Server 2005 and 2008
i want to know how it is possible to use the Entity Framework against the SQL Server 2008 and 2005? 我想知道如何对SQL Server 2008和2005使用实体框架?
I develop a application against the SQL Server 2008 and want that it can run under 2005 and 2008. I know that it is possible to change the ProviderManifestToken from 2008 to 2005 in the edmx Schema File in a Texteditor. 我针对SQL Server 2008开发了一个应用程序,并希望它可以在2005和2008下运行。我知道可以在Texteditor的edmx Schema文件中将ProviderManifestToken从2008更改为2005。 But after i update my Model from the Database it changes the ProviderManifestToken back to 2008.
但是在我从数据库更新我的模型后,它将ProviderManifestToken更改回2008。
How can i told Visiual Studio to use the the 2005 Schema when i update my model from Database? 当我从数据库更新我的模型时,我如何告诉Visiual Studio使用2005 Schema?
Thanks for any Help! 谢谢你的帮助!
Nico 尼科
Read my blog post on EF and ProviderManifestToken. 阅读我关于EF和ProviderManifestToken的博文 。
Using the MSBuild.Community Tasks , I added a BeforeBuild Target that uses the XmlUpdate task to always change the ProviderManifestToken to 2005, in case someone changed it by updating the data model. 使用MSBuild.Community Tasks ,我添加了一个BeforeBuild Target,它使用XmlUpdate任务始终将ProviderManifestToken更改为2005,以防有人通过更新数据模型对其进行更改。
Here is the BeforeBuild Target: 这是BeforeBuild目标:
<Target Name="BeforeBuild"> <XmlUpdate Prefix="ssdl"
Namespace="http://schemas.microsoft.com/ado/2009/02/edm/ssdl"
XPath="//ssdl:Schema/@ProviderManifestToken"
XmlFileName="Model.edmx"
Value="2005"/>
I think the manual (hack!) edmx change is the only way at the moment. 我认为手册(黑客!)edmx改变是目前唯一的方式。 Particularly annoying when you forget and deploy it to an environment with 2005. :)
当你忘记并将它部署到2005年的环境时特别烦人。:)
I'd like to know another way... 我想知道另一种方式......
The easiest way is to put your source database into SQL 2005 compability mode (level 90) on your SQL 2008 server. 最简单的方法是在SQL 2008服务器上将源数据库置于SQL 2005兼容模式(级别90)。 You can use ALTER DATABASE to do that.
您可以使用ALTER DATABASE来执行此操作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.