Created
December 15, 2015 10:43
-
-
Save Antaris/74565b097d04d9eac0bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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