Skip to content

Instantly share code, notes, and snippets.

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