I have successfully created a migration file using .NET Core class library by using command: dotnet ef --startup-project ../Project.Web migrations add Init
Because I register my db context in a different layer, (web layer), and have class library, I have to set my startup project to Project.Web.
After creating my initial migration it looks something like this:
But now I would like to move the migration folder Project.Data/Migrations to Project.Data/Database/Migrations
I have tried using the output-dir parameter:
dotnet ef --startup-project ../Project.Web --output-dir Database migrations add Init
But then I get:
dotnet : Unrecognized option '--output-dir'
Startup (in a different project, business layer)
public static IServiceCollection InjectBusinessContext(this IServiceCollection services, string connectionString)
{
services.AddEntityFrameworkSqlServer().AddDbContext<ProjectContext>((serviceProvider, options) => options.UseSqlServer(connectionString, b => b.MigrationsAssembly("Database")).UseInternalServiceProvider(serviceProvider));
return services;
}
Context (data layer)
public class ProjectContext : DbContext
{
public ProjectContext(DbContextOptions<ProjectContext> options) : base(options)
{
}
public DbSet<Account> Account { get; set; }
}
