Migration "our target project 'xxx' doesn't match your migrations assembly 'xxx'" using aspnet Core 1.0 RC2 -
Asked Answered
S

2

2

I'm trying to build the migration classes for a second DBContext in a assembly. using this command: Add-Migration AlertInitial -c Axper.Data.Persistence.Context.AlertContext and using the "Package Console management"

But it fail and give me this error:

Your target project 'AxPortal' doesn't match your migrations assembly 'Axper.Data.Persistence'. 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("AxPortal")). 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.

I can't figure what this error mean, and what to do to fix it. Can someone help?

Scanderbeg answered 27/5, 2016 at 19:15 Comment(1)
I like to but the project that hold the migration class, is a Class Library. And since RC2, Class Library isn't supported yet.Scanderbeg
S
3

For unknown reason, my projects/Solution folder was kind of corrupted. I deleted I and re-cloned the Git Repository. I i finally been able to do the migration.

Scanderbeg answered 31/5, 2016 at 14:14 Comment(1)
This was my problem. To be sure I closed the solution, deleted the .vs, bin and obj folders and then re-opened the solution. The problem was solved.Beata
K
3

options.UseSqlServer(connection, b => b.MigrationsAssembly("WebApplication3")). By default, the migrations assembly is the assembly containing the DbContext.

services.AddDbContext<ComDbContext>(options =>
            {
                options.UseSqlServer("server=.\\sqlexpress;database=dsafdsaf;uid=sa;pwd=123456", b => b.MigrationsAssembly("WebApplication3"));
            });
Karalee answered 31/12, 2016 at 7:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.