none
Different ModelHash on different sql server RRS feed

  • Question

  • Hello, if have a project using the identityframework.

    We make a backup of the productionserver and restore this backup on a different testserver. (both SqlServer express at this time)

    This testserver is located on a physically different location.

    Each time we do this, the ModelHash of the backup is different from the original and a exception is generated when we point the application to the testdatabase.

    Is there a way to prevent this? Does anyone knows what criteria are used to create the modelhash?

     

    Wednesday, January 4, 2012 12:54 PM

Answers

  • Hi RCaspers,

    I tested on my computer. Back up a database and retrieve the .bak file, then restore it to another server, I got the same ModelHash, I'm not sure what's the root cause of the problem. If your OS version, sql server version, EF version are all same, it ought to create the same ModelHash. Another workaround, you can disable the hash creation/checking by removing the convention. Please add the code below

    modelBuilder.Conventions.Remove<IncludeMetadataConvention>();

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, January 11, 2012 3:02 AM
    Moderator

All replies

  • Hi RCaspers,

    Welcome to MSDN Forum.

    Is the version of EF in two servers are same? If the version are different in the two servers, even though both of them are EF4.1 or EF4.2, but one is pre-release version and the other is RTF version, it will generate different modelhash.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Friday, January 6, 2012 3:51 AM
    Moderator
  • Hi there,

    Thanks for your reply

    EF versions are equal.

    We use exactly the same executable and switch from one sql server to an other by changing the connection string

    in the config file.

    Then it complains about the modelhash.

     

    Regards

    René Caspers

     



    • Edited by RCaspers Tuesday, January 10, 2012 9:06 AM
    Tuesday, January 10, 2012 9:04 AM
  • Hi RCaspers,

    How do you make the same database in your second machine? If you execute the T-SQL to create the database, it certainly will generate the different modelhash.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us
    Tuesday, January 10, 2012 9:24 AM
    Moderator
  • Hi Allen

    The database on the test server is a restored backup from the production server.

    It is made using Sql Server Management Studio.

    Even the username and password to connect to sqlserver are the same

    Best Regards

    Tuesday, January 10, 2012 10:33 AM
  • Hi RCaspers,

    I tested on my computer. Back up a database and retrieve the .bak file, then restore it to another server, I got the same ModelHash, I'm not sure what's the root cause of the problem. If your OS version, sql server version, EF version are all same, it ought to create the same ModelHash. Another workaround, you can disable the hash creation/checking by removing the convention. Please add the code below

    modelBuilder.Conventions.Remove<IncludeMetadataConvention>();

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, January 11, 2012 3:02 AM
    Moderator