find and solve || findandsolve.com
Please wait.....

Your target project xx does not match your migrations assemblyEither change your target project or change your migration

Your target project xx does not match your migrations assemblyEither change your target project or change your migration

PM> Add-migration AddURLandUserType

Build started...

Build succeeded.

Microsoft.EntityFrameworkCore.Model.Validation[30000]

      No type was specified for the decimal property 'FileSize' on entity type 'SourceCode'. This will cause values to be silently truncated if they do not fit in the default precision and scale. Explicitly specify the SQL server column type that can accommodate all the values in 'OnModelCreating' using 'HasColumnType()', specify precision and scale using 'HasPrecision()' or configure a value converter using 'HasConversion()'.

Your target project 'XXX' doesn't match your migrations assembly 'Repository'. Either change your target project or change your migrations assembly.

Change your migrations assembly by using DbContextOptionsBuilder. E.g. options.UseSqlServer(connection, b => b.MigrationsAssembly("XXX")). By default, the migrations assembly is the assembly containing the DbContext.

Change your target project to the migrations project by using the Package Manager Console's Default project drop-down list, or by executing "dotnet ef" from the directory containing the migrations project.

Answer


Option 1.

cd ../Model
dotnet ef --startup-project ../TestWeb/ migrations add Initial

Option 2.

Add-Migration -StartupProject YourApp.Web -Context "YourDbContext" Initial

or

dotnet ef --startup-project ../XXXX.API migrations add MigrationName -c MyContext

Option 3.

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):




Selena  Kandakar

Selena Kandakar

I like working on projects with a team that cares about creating beautiful and usable interfaces.

Comments



Report Response