Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp core ef migrations on production server

Can't perform migrations on production server. Command "dotnet ef database update" works on my computer but fails on production Steps i tried are: 1. Fill in checkbox execute code first migrations in Visual Studio before publish. 2. dotnet ef database update not working . I installed .NET SDK but it doesn't have libraries needed.

Any suggestions appeciated.

like image 563
Lapenkov Vladimir Avatar asked Oct 17 '16 07:10

Lapenkov Vladimir


People also ask

How do I enable-migrations on my ef core?

Migrations are enabled by default in EF Core. They are managed by executing commands. If you have Visual Studio, you can use the Package Manager Console (PMC) to manage migrations. Alternatively, you can use a command line tool to execute Entity Framework CLI commands to create a migration.

Is entity framework used in production?

Entity Framework can be useful for getting up and running quickly with a database application, but when it comes to deployment, EF's built-in data migration feature doesn't inspire confidence.


1 Answers

There are a couple options:

  1. Generate a SQL script using dotnet ef migrations script and run it on your production database.
  2. Call dbContext.Database.Migrate() at runtime during application startup (but be careful when running multiple apps/database clients)

Also, in the next release (1.0.0-preview3) of Microsoft.EntityFrameworkCore.Tools, we'll be shipping ef.exe which you can point directly to assemblies (instead of project.json files) to perform migrations.

like image 76
bricelam Avatar answered Nov 06 '22 12:11

bricelam