Skip to content

Instantly share code, notes, and snippets.

@jesslilly
Created April 9, 2018 13:11
Show Gist options
  • Save jesslilly/5fad464839a41daa5e79aa5e027fb15d to your computer and use it in GitHub Desktop.
Save jesslilly/5fad464839a41daa5e79aa5e027fb15d to your computer and use it in GitHub Desktop.
Simple IDesignTimeDbContextFactory example
public class FooDbContextFactory : IDesignTimeDbContextFactory<FooDbContext>
{
public FooDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<FooDbContext>();
optionsBuilder.UseSqlServer("DeaultConnection");
return new FooDbContext(optionsBuilder.Options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment