Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8493605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:03:52+00:00 2026-06-10T23:03:52+00:00

We have a plethora of databases all sharing the same schema. They are spread

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T23:03:54+00:00Added an answer on June 10, 2026 at 11:03 pm

    There is an overload for the base class constructor!

    I copied my OnModelCreating configuration stuff into a new method that returns DbCompiledModel named BuildModel. When my constructor that has ConnectionString constructor is called, I get the value of dbModel, a private readonly property which if null, gets set to the value returned from BuildModel. The property value gets fed to the base class constructor along with the connection string.

    I have access to the SQL server versions that I am connecting to. Eventually I will bring that in and create one model for 2005 and one for 2008.

    I will leave this open for a while just in case there is a better way to do this.

    public DbContext ProjectContext (string ConnectionString) 
        : base(ConnectionString, dbModel)
    {
    
    }
    
    private DbCompiledModel _dbModel;
    private DbCompiledModel dbModel;
    {
        get
        {
            if (_dbModel == null)
            {
                _dbModel = BuildModel(new DbModelBuilder());
            }
            return _dbModel;
        }
    }
    
        private DbCompiledModel BuildModel(DbModelBuilder builder)
        {
            //Some configuration stuff
            return builder.Build(new DbProviderInfo("System.Data.SqlClient", "2005"))
                          .Compile();
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database of about 700k users along with items they have watched/listened
I have an application which depends on a plethora of libraries (don't we all).
We're using SQL Server 2005 in a project. The users of the system have
Have deployed numerous report parts which reference the same view however one of them
Despite the plethora of URL routing posts, I have yet to reach enlightenment on
I know this question has been asked before and I have seen a plethora
I recently started learning Ruby and Ruby on Rails, and have watched a plethora
I am reading about WCF Transport Security and I get a plethora of doubts
Im kinda confuse about the thing creating a website for mobile; Say I have
I have created a C++/CLI wrapper around some library. When I inspect the compiled

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.