Home > front end >  Add-Migration could not find referenced assembly - But it is referenced
Add-Migration could not find referenced assembly - But it is referenced

Time:11-10

I am trying to update the Migration, however, it says the package is not referenced even though I set the default project to the correct one. See the image below. In fact, I can start the program and access the database correctly. Not sure what it causing it.

Referenced Message

I am referencing it in program.cs

builder.Services.AddSqlServerContext<LairageContext>(configuration.GetConnectionString("Lairage"));

...

public static IServiceCollection AddSqlServerContext<TContext>(this IServiceCollection services, string connectionstring, ServiceLifetime serviceLifetime = ServiceLifetime.Scoped) where TContext : DbContext => services
        .AddDbContext<TContext>(options => options.UseSqlServer(
                connectionstring,
                actions => actions.MigrationsAssembly("Marel.Lairage.Innova.Data")
                                  .EnableRetryOnFailure()
            ), serviceLifetime);

CodePudding user response:

try to do Update-Database after Add-Migration, and close Visual Studio and re-opened it, then re-ran Update-Database again

CodePudding user response:

Not ideal, but I was able to fix the issue by deleting my database.

  • Related