Entitfy Framework: everything is broken when I change schema -
Entitfy Framework: everything is broken when I change schema -
i utilize ef code-first approach.
i have class:
public class cat { // ... }
then add together properties , migrations them. have couple of existing migrations. create abstract class:
public abstract class animal { // ... }
and inherit cat animal:
public cat : animal { // ... }
when that, , run add-migration run problem can't solve. ef gives me error:
unable generate explicit migration because next explicit migrations pending: [...]. apply pending explicit migrations before attempting generate new explicit migration.
this because schema stored in __migrationhistory. , when ef tries compare current schema schema fetched database (from __migrationhistory), fails.
everything's fine when drop of migrations , create database scratch.
but don't want drop entire database when schema changes.
how can handle schema changes ef?
here similar post, without solution.
if ran add-migration
, didn't run update-database
run it.
but times run next command:
pm>add-migration migration1
then create changes model, in case if want add together migration, mentioned error, have 2 options:
runupdate-database
apply pending changes of migration1 database , add together new migration. run add-migration migration1 -force
add together pending migrations migration1 , run update-database
. entity-framework
Comments
Post a Comment