I need read the value connection string of appsettings.json for have this dynamic.
I have:
public class StoreContextFactory : IDesignTimeDbContextFactory<StoreContext>
{
public StoreContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<StoreContext>();
optionsBuilder.UseSqlServer(@"Server=localhost;Database=StoreCleanArchitecture;Trusted_Connection=True;");
return new StoreContext(optionsBuilder.Options);
}
}
I need:
public class StoreContextFactory : IDesignTimeDbContextFactory<StoreContext>
{
public StoreContext CreateDbContext(string[] args)
{
var defaultConnectionString = configuration.GetConnectionString("DefaultConnection");
var optionsBuilder = new DbContextOptionsBuilder<StoreContext>();
optionsBuilder.UseSqlServer(defaultConnectionString);
return new StoreContext(optionsBuilder.Options);
}
}
Thx.