Skip to content

Instantly share code, notes, and snippets.

@tonysneed
Last active December 20, 2018 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonysneed/7717ccac25899bf823e88fe31e657bc1 to your computer and use it in GitHub Desktop.
Save tonysneed/7717ccac25899bf823e88fe31e657bc1 to your computer and use it in GitHub Desktop.
ProductsDbContextFactory1
public class ProductsDbContextFactory : IDesignTimeDbContextFactory<ProductsDbContext>
{
public ProductsDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<ProductsDbContext>();
var connectionString = "Data Source=(localdb)\\MsSqlLocalDb;initial catalog=ProductsDbDev;Integrated Security=True; MultipleActiveResultSets=True";
optionsBuilder.UseSqlServer(connectionString, b => b.MigrationsAssembly("EfDesignDemo.EF.Design"));
return new ProductsDbContext(optionsBuilder.Options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment