Your target project 'x' doesn't match your migrations assembly 'xx'. Either change your target project or change your migrations assembly

asp.net-core c# entity-framework-core

Question

.net core 3.0. I have a LibraryProject(SyWaterStandardLibrary), There's a DbContext.When I build new WebProject(WebApplicationTestLibrary) and using LibraryProject.

Startup:

  services.AddDbContext<LocalContext>(options =>
                options.UseSqlServer(Configuration.GetConnectionString("SMS"), 
                optionsBuilder => optionsBuilder.MigrationsAssembly("WebApplicationTestLibrary"))
               );

When I execute: add-migration init -context localcontext

An error has occurred:Your target project 'WebApplicationTestLibrary' doesn't match your migrations assembly 'SyWaterStandardLibrary'. Either change your target project or change your migrations assembly.

This exception does not exist in .net core 2.2. What's the matter, please.

Edit 1: WebApplicationTestLibrary

SyWaterStandardLibrary

1
0
12/10/2019 11:09:29 AM

Popular Answer

When you run any Entity Framework Core command from the Package Manager Console within Visual Studio, the default project must be your migration assembly SyWaterStandardLibrary. Here's a picture showing how to change it (here, my migration assembly is called Model):

How to set the default project in the Package Manager Console

Note that this is not the same as the startup project.

1
12/10/2019 1:39:56 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow