Last post Oct 17, 2016 06:02 AM by Cathy Zou
Oct 14, 2016 11:56 AM|tvb2727|LINK
In my development I am already using SQL Server 2014. So when I make my Model, then the providermanifesttoken is set to 2012 - which is correct. The problem I have is that my testing environment and production environment are still on SQL server 2008,
so I receive the error below. Is there a way to update this via the code instead of going into the XML of my edmx and doing the update?
Exception type: System.Data.SqlClient.SqlException Exception message: Incorrect syntax near 'OFFSET'
Here is a link with the issue:
Oct 17, 2016 06:02 AM|Cathy Zou|LINK
As far as I know, DbModelBuilder class takes a DbProviderInfo in its Build method. So, you could to configure providerManIfestTo for EF code first.
// 'Entities' is my DbContext subclass, the "container" in EF terms.
public static Entities GetNewContext()
// Get a connection, for example:
var connection = new SqlConnection(GetConnectionString());
// Create a DbModelBuilder
var modelBuilder = new DbModelBuilder();
// Configure the model builder.
// I changed my DbContext subclass - added a public version of OnModelCreated and called it ConfigureModelBuilder
// Here's where the magic happens.
// Build the model and pass the ProviderManifestToken (I use 2005 to avoid a bug in precision of sql datetime columns when using concurrency control)
var model = modelBuilder.Build(new System.Data.Entity.Infrastructure.DbProviderInfo("System.Data.SqlClient", "2005"));
// Compile the model
var compiledModel = model.Compile();
// Create the container (DbContext subclass). Ideally all the previous stuff should be cached.
return new Entities(connection, compiledModel, true);
You also could take a look at the article below: