Reputation: 1025
I am attempting to update my database and Add-Migration. I am getting the following errors:
PM> Add-Migration update
No migrations configuration type was found in the assembly 'Infrastructure'. (In Visual Studio you can use the Enable-Migrations command from Package Manager Console to add a migrations configuration).
PM>Enable-Migrations
No context type was found in the assembly 'Infrastructure'.
DbContext is located inside Infrastructure. I have five previous Migrations that have been completed without error. I have not changed my DbContext method in between the last migration and the one I am attempting now.
Infrastructure.Data:
namespace Infrastructure.Data
{
public class MovieshopDBContext : DbContext
{
//will generate the DB tables
public MovieshopDBContext(DbContextOptions<MovieshopDBContext> options) :base(options)
{
//specify options
}
public DbSet<Genre> Genres { get; set; }
public DbSet<Movie> Movies { get; set; }
public DbSet<Trailer> Trailers { get; set; }
public DbSet<Cast> Casts { get; set; }
public DbSet<Crew> Crews { get; set; }
public DbSet<Favorite> Favorites { get; set; }
public DbSet<MovieCast> MovieCasts { get; set; }
public DbSet<MovieCrew> MovieCrews { get; set; }
public DbSet<MovieGenre> MovieGenres { get; set; }
public DbSet<Purchase> Purchases { get; set; }
public DbSet<Review> Reviews { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<UserRole> UserRoles { get; set; }
}
}
I have what I believe are all of the necessary dependencies and NuGet packages installed. Things I have tried: Rebuilt, reran commands with -force. Restarted machine. Checked Microsoft.docs.com.
Upvotes: 1
Views: 7509
Reputation: 31
In my case with Package EntityFrameworkCore 6.0.4 it was solved by simply closing Visual Studio and delete the hidden .vs folder in the solution directory.
Additional gotcha: Always make sure you specify the correct target project, either via CLI or by selecting the data layer project in the Package Manager Console.
Upvotes: 0
Reputation: 1025
After hours and hours of searching, I found the answer:
Credit to: Henryk Budzinski on SO
Worked for me flawlessly.
Upvotes: 1