I want to be able to change the connectionstring of IDesignTimeDbContextFactory in run time.
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<erp_colombiaDbContext>
{
public erp_colombiaDbContext CreateDbContext(string[] args)
{
var options = new DbContextOptionsBuilder<erp_colombiaDbContext>().UseMySql(
@"SECRECT CONNECTION STRING SHOULD BE PARAMETER",
optionsBuilder => optionsBuilder.MigrationsAssembly(typeof(DesignTimeDbContextFactory).Assembly.FullName))
.Options;
return new erp_colombiaDbContext(options);
}
When I am generating the data here I have some tables that should be in a diffrent database
public class erp_colombiaDbContext : IdentityDbContext<Employee, Entities.Type, ulong>
{
public erp_colombiaDbContext(DbContextOptions options) : base(options)
{
}
protected override void OnModelCreating(ModelBuilder builder)
{
//For exemple the family should be in database 2
builder.Entity<Family>().HasIndex(t => t.FamilyName).IsUnique();
//And the news author should be in database 1
builder.Entity<NewsAuthor>().HasKey(t => new { t.NewsId, t.EmployeeId });
}
}