Skip to content

Instantly share code, notes, and snippets.

@Antaris
Created December 15, 2015 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Antaris/74565b097d04d9eac0bc to your computer and use it in GitHub Desktop.
Save Antaris/74565b097d04d9eac0bc to your computer and use it in GitHub Desktop.
public abstract class StartupBase
{
public virtual void ConfigureService(IServiceCollection services)
{
// Standard registrations
ConfigureEntityFramework(services);
}
public abstract void ConfigureEntityFramework(IServiceCollection services);
public IConfiguration Configuration { get; set; }
}
public class Startup : StartupBase
{
public override void ConfigureEntityFramework(IServiceCollection services)
{
services.AddEntityFramework()
.AddNpgsql()
.AddDbContext<ApplicationDbContext>(options => options.UseNpgsql(Configuration["Data:DefaultConnection:ConnectionString"]));
}
}
public class TestStartup : StartupBase
{
public override void ConfigureEntityFramework(IServiceCollection services)
{
services.AddEntityFramework()
.AddInMemoryDatabase()
.AddDbContext<ApplicationDbContext>(options => options.UseInMemoryDatabase());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment