How to Create Migration on Runtime in Entity Framework Core

送分小仙女□ 提交于 2021-01-29 16:07:08

问题


Is there any possible way to create migration on runtime in efcore.

context.Database.Migrate();

Before this code, I need a code that, when I started my app, should create a migration about diff between postgresql database tables and ef models.

Is there any way to do this?

PM> enable-migrations
PM> add-migration initial
PM> update-database

I dont want to use these ones. I want to make these code's jobs on runtime. I hope I could explain myself clearly.


回答1:


Note, you need to re-compile the app after calling Add-Migration. It's very difficult to do this while the app is running.

Have a read through the closed Automatic Migrations issue for some alternative solutions.



来源:https://stackoverflow.com/questions/61304019/how-to-create-migration-on-runtime-in-entity-framework-core

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