c# - Entity Framework migrations under the hood -


i've been using entity framework migrations time , started wondering how work under hood. mean following:

how ef understand model in application , db scheme different? far know, there's table __migrationhistory in database migrations stored in migrations folder in application (applies code-based migrations). in __migrationhistory table, there's column called model contains kinda hash. hash exactly? snapshot of model? changes ef needs apply previous migration one?

if model snapshot, mean ef have figure out how transform current model snapshot each time decided update database.

however, if changes, mean ef have apply changes current model in order understand when db model , application model different.

the question is, can read how migrations implemented , model column in database. appreciate advices or links.

update:

i've checked resources provided , i've found out, model column snapshot of model. means, when run update-database command, ef goes db, checks latest migration model decoding xml string , if current model in application , model ef got db different, ef generates script update db. however, still don't know ef when there multiple migrations pending.

i describe on example based on example https://channel9.msdn.com/blogs/ef/migrations-under-the-hood. say, have first migration in db, second migration, adds url column , third one, drops column. if apply these changes db contains schema similar first, ef add column , drop according second , third, or try calculate general changes required update db , execute generated script (in example case nothing?

also, there's link i've found if anyone's interested https://msdn.microsoft.com/en-us/data/dn481501.aspx

this channel 9 video covers general concepts. blog post might more specific question. in particular, author concludes on use of model column (spoiler: compressed xml string can decompress , inspect, has code so).


Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -