Programmatic data transformation in EF5 Code First migration

萝らか妹 提交于 2019-11-29 11:52:58
NSGaga

You should use db 'initializer' for what you want - and/ore 'Seed' of a sort (as to where to inject into the EF flow).

You can > take a look at this post with a customized < initializer - that performas both Db Create... and Migrate. It's not cut and paste solution, but mostly works (it was just a fast go at the problem, you'd need to adjust a bit, it has couple fixes below).

MigrateDatabaseToLatestVersion dose only the migration part - and you need seed-ing exposed - or manually wrap that part (the main point is in 'checks' done for different situations - i.e. when to 'engage' into migration - or seeding).

Migration should go first, and db 'creation' kind of doesn't make much sense, except for seeding.

You override Seed (you created) to put any db handling there - you have the DbContext exposed - and you can also call SqlQuery if needed.


How to create initializer to create and migrate mysql database?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!