EntityFramework 4.1 EdmMetadata ModelHash
I am trying to deploy an EF 4.1 Code-First application from Dev to Test without letting EF "blow-away" the entire database.
I copy the database over from Dev to Test, rebuilt the application and deploy the code. For EF still thinks it needs to rebuild the DB or that the data models are different. How can I predict which ModelHash the application will want to see when it is deployed to a different server?
As far as I can开发者_StackOverflow社区 tell, the only difference between the two builds is the configuration I use to build them (one is Test, and the other Dev).
If you want someone else to use your DB and now have to Re Create it each time.
I set my DB Initializer = CreateDatabaseIfNotExists
Then delete the "EdmMetadata" table from the DB.
I am not sure if this is the "correct" way to do it. But it works for me.
System.Data.Entity.Infrastructure.EdmMetadata.TryGetModelHash(DbContext)
will return you hash string of the model. That's what the EF want to see in ModelHash column at EdmMetadata table.
精彩评论