ÖMER HATİP
ÖMER HATİP

Reputation: 126

How to Create Migration on Runtime in Entity Framework Core

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.

Upvotes: 1

Views: 2822

Answers (1)

bricelam
bricelam

Reputation: 30425

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.

Upvotes: 2

Related Questions