Reputation: 16042
Im using EF 4.3 with explicit migrations. When defining a new migration and calling Update-Database on my local dev db everything is working fine and only the not applied migrations are applied to the db.
But when i try to migrate another db (that is in the same state as my dev db before migrating) with
Update-Database -ConnectionStringName=MyProdConnectionStringName
it seems that the db state and the existing __MigrationHistory table is ignored and the ef applies all migrations to my prod db which of cause fails because there are already some tables there.
Maybe its relevant to know, that i use a custom schema for my tables with [Table("TabName", Schema = "stepid")]
. The __MigrationHistory table has the default schema of the database (dbo on my dev machine and projects on my prod environment).
Upvotes: 1
Views: 235
Reputation: 16042
Ok, it seems that the __MigrationHistory table has to be in the schema dbo
. EF migrations will use the default schema of the database when creating it (in my case its called "projects") and afterwards when calling Update-Database
it won't query that table but assumes that there was never any migration applied to the db.
When i manually change the schema to dbo it works like it should.
Upvotes: 0