Skip to content

Instantly share code, notes, and snippets.

@jpvelasco
Last active March 24, 2017 07:13
Show Gist options
  • Save jpvelasco/8aa6d718d5d051685afdff324ebf7276 to your computer and use it in GitHub Desktop.
Save jpvelasco/8aa6d718d5d051685afdff324ebf7276 to your computer and use it in GitHub Desktop.
Sample implementation of IDBContextFactory for Entity Framework Core tooling
public class EventDbContextFactory : IDbContextFactory<EventDataContext>
{
public EventDataContext Create(DbContextFactoryOptions options)
{
var builder = new DbContextOptionsBuilder<EventDataContext>();
builder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=SampleApiDatabase;Trusted_Connection=True;");
return new EventDataContext(builder.Options);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment