We have a plethora of databases all sharing the same schema. They are spread about on a number of SQL Servers, some 2005, some 2008. We are getting an exception when connecting to a 2005 server AFTER having connected to a 2008 server first stating the following:
An error occurred while updating the entries. See the inner exception for details. An error occurred while updating the entries. See the inner exception for details. The version of SQL Server in use does not support datatype 'datetime2'.
So as I understand it what is happening is the Model is being created according to a 2008 SQL servers provider info, and thus when connected to a 2005 server, it can't use the DateTime2 data type because that is not supported there.
We would like to build the model against a 2005 server, but I am unsure of how to specify both the connection string AND the DbCompiledModel. Previously I have had a couple of constructors that take the connection string (among other parameters)...
public ProjectContext(string ConnectionString) : base(ConnectionString)
{
// Get the ObjectContext related to this DbContext
var objectContext = (this as IObjectContextAdapter).ObjectContext;
// ... does some stuff with the ObjectContext
}
How can I specify the compiled model built against a 2005 server for ALL contexts (lowest common denominator) and also specify the connection string? I just don't see a way to do it at the moment.
Any help would be appreciated.
Edit: We are using Entity Framework 4.3 Code First, thus, there is not a design time EDMX file to edit.