entity framework - Update-Database fails on production server -
i've enabled migrations asp.net mvc project. migrations work on localhost. following exception after deploying server:
unable update database match current model because there pending changes , automatic migration disabled. either write pending model changes code-based migration or enable automatic migration. set
dbmigrationsconfiguration.automaticmigrationsenabled
true enable automatic migration.
view stack trace
there no pending migrations, though. adding new migration creates empty up()
& down()
what reason doesn't work on server? i've tried deleting migrations folder, re-enabling migrations, deleting database, , let ef afresh. tables created, end exception.
update:
thing noticed is, when delete migration folder not database, , enable migrations, adds configuration.cs file, when it's supposed add file (initialcreate.cs)
this happens when doing tow different query on same list of objects on same time without using .tolist
example :
you can create context , list of testobjects edit 1 of objects save changes
var objectslist = context.testobjects.where(x=>x.whatever=true) objectslist[0].whatever2="asd" context.savechanges()
the above code pass compailer , fail while running, solve should below
var objectslist = context.testobjects.where(x=>x.whatever=true).tolist() objectslist[0].whatever2="asd" context.savechanges()
Comments
Post a Comment