Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
Migration in different assembly than target assembly not supported #5900
Steps to reproduce
Create Web project that injects and initializes the DbContext and a Models project with the DbContext and migrations
Your target project '#Target Project#' doesn't match your migrations assembly '#Migrations Assembly#'. Either change your target project or change your migrations assembly.
Thanks for the repro. You will see the error when invoking EF commands on the "Web" project.
The exception message you are seeing is by-design.
All EF commands have this check:
As the error message suggests, you have have a two options to resolve this
1 - Change target assembly.
2 - Change the migrations assembly.
options.UseSqlServer(connection, b => b.MigrationsAssembly("Web"))
If you are still getting this error message even after changing either your migration assembly or your target assembly, please feel free to re-open the issue.
Looks good i was placing the --startup-project on the database command and not the ef command..
the help file doesnt seem to have this option
dotnet ef --help
--project-dir The folder used as the project directory (defaults to current working directory).
--content-root-path The folder used as the content root path for the application (defaults to application base directory).
--root-namespace The root namespace of the target project (defaults to the project assembly name).
database Commands to manage your database
dbcontext Commands to manage your DbContext types
migrations Commands to manage your migrations
Use "dotnet ef [command] --help" for more information about a command.
See https://docs.efproject.net/en/latest/miscellaneous/cli/dotnet.html for the "true" set of available parameters.
@natemcmaster could you advise on following:
Earlier those issues can be resolved by storing particular dll and running migrate.exe on them. so the defined migrations in these dlls ran.
How could i use dotnet ef on the particular package to do the migrations defined in the particular package?
Below is the command for Package Manager Console (Select YourApp.Data in Target Project dropdown )