Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

782
Visualizações
How to apply EF Core migrations if you should not use MigrateAsync() for production environments?

I created a new .Net 5 project and want to use EF Core. I autogenerated multiple migration.cs files using

dotnet ef migrations add MyMigration

and want to apply them (for development and production). I know about the MigrateAsync method so I read about how to call this method on startup

https://andrewlock.net/running-async-tasks-on-app-startup-in-asp-net-core-part-1/

but everywhere I read that this method should not be used for production since those migrations won't be executed in a single transaction (no rollback on errors).

Unfortunately there are not many resources on how to do it regardless of the environment, I found this article

https://www.thereformedprogrammer.net/handling-entity-framework-core-database-migrations-in-production-part-2

One option could be a console app calling the migrations

https://www.thereformedprogrammer.net/handling-entity-framework-core-database-migrations-in-production-part-2/#1b-calling-context-database-migrate-via-a-console-app-or-admin-command

but I wasn't able to understand the difference for this approach because it's not solving the transactional problem?

What are best practises to apply migrations during development/production?

  • After autogenerating migrations I'm a big fan of simplicity, does dotnet ef database update the job and I don't need to work with additional tools?

  • Create a console app, generate .sql files from the migrations, install DbUp and use it for the migration part?

over 4 years ago · Santiago Trujillo
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda