Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

.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

like image 427
jiaxiang8756 Avatar asked Dec 10 '19 10:12

jiaxiang8756


1 Answers

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.

like image 157
Métoule Avatar answered Sep 21 '22 15:09

Métoule