Skip to content

Instantly share code, notes, and snippets.

@tonysneed
Created December 20, 2018 22:26
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/d74b6545e6a8eda85eddbff7accf3730 to your computer and use it in GitHub Desktop.
Save tonysneed/d74b6545e6a8eda85eddbff7accf3730 to your computer and use it in GitHub Desktop.
ProductsDbContextFactory4
public class ProductsDbContextFactory : IDesignTimeDbContextFactory<ProductsDbContext>
{
public ProductsDbContext CreateDbContext(string[] args)
{
// Get DbContext from DI system
var resolver = new DependencyResolver
{
CurrentDirectory = Path.Combine(Directory.GetCurrentDirectory(), "../EfDesignDemo.Web")
};
return resolver.ServiceProvider.GetService(typeof(ProductsDbContext)) as ProductsDbContext;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment