chris
chris

Reputation: 37470

LINQ to Entities, SQL Server version and setting ProviderManifestToken at runtime

We have developers some developers who are developing against a SQL Server 2005 database, while others are using 2008.

We just discovered that generating the edmx against a 2008 database set the ProviderManifestToken to 2008, which means some queries won't work against a 2005 database.

While this is a known issue, is there any way to set this value at run time, based on a config file?

Upvotes: 2

Views: 514

Answers (1)

jnosek
jnosek

Reputation: 4253

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.

Here is the BeforeBuild Target:

<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"/>

Upvotes: 2

Related Questions