How to generate entity framework code-first migrations without using the package manager console?

1.4k views Asked by At

Does anybody know how to generate entity framework code first migrations without having to use the package manager console?

I'm having a significant problem whereby on occasion running add-migration or update-database causes visual studio to freeze. I end up having to kill the process and restart visual studio to be able to start working again, and its very annoying.

I've had no luck tracking the issue down, and am trying to separate the generating and running of migrations from visual studio. I've found the article below which explains how to run migrations, but it doesn't generate migrations.

https://msdn.microsoft.com/en-us/data/jj618307.aspx

Any help would be greatly appreciated

1

There are 1 answers

0
iSA SAYIN On

In Ef Core DbContext.Database has Migrate method which creates the database and aplly all migrations if needeed.

It does not reset an existing database nor do any harm.

DbContext.Database.Migrate()