jasontaylordev/CleanArchitecture

Migrations Issues

fernandohermida opened this issue · 0 comments

Discussed in #1115

Originally posted by fernandohermida February 21, 2024
Hello everyone,
I'm currently facing several challenges with database migrations in my project and would greatly appreciate some guidance.

Here's what I'm trying to accomplish:

  1. Remove the initial migration along with the associated tables database of the template.
  2. Create a new migration that reflects the latest changes to my models.
  3. Apply this new migration to update the database schema accordingly.

While the process may seem straightforward, I've encountered difficulties despite trying various approaches.

Could someone kindly provide insights or suggestions on how to tackle this issue effectively?

some error i found in the console using CLI commands
Unable to create a 'DbContext' of type ''. The exception 'No database provider has been configured for this DbContext. A provider can be configured by overriding the 'DbContext.OnConfiguring' method or by using 'AddDbContext' on the application service provider. If 'AddDbContext' is used, then also ensure that your DbContext type accepts a DbContextOptions<TContext> object in its constructor and passes it to the base constructor for DbContext.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

More erros
Unable to create a 'DbContext' of type ''. The exception 'Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions1[Project.Infrastructure.Data.ApplicationDbContext]' while attempting to activate 'Project.Infrastructure.Data.ApplicationDbContext'.' was thrown while attempting to create an instance. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728`

and if i use VS comands im getting this Your startup project 'Project.Web' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.