问题
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