Reacting to changes in EF service registration.
This commit is contained in:
parent
d56274040f
commit
a4ed79cc5a
|
|
@ -47,16 +47,12 @@ namespace MusicStore
|
|||
// Add EF services to the services container
|
||||
if (useInMemoryStore)
|
||||
{
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseInMemoryDatabase());
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddEntityFramework()
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,16 +53,12 @@ namespace MusicStore
|
|||
// Add EF services to the services container
|
||||
if (useInMemoryStore)
|
||||
{
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseInMemoryDatabase());
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddEntityFramework()
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,11 @@ namespace MusicStore.Models
|
|||
|
||||
public class MusicStoreContext : IdentityDbContext<ApplicationUser>
|
||||
{
|
||||
public MusicStoreContext(DbContextOptions<MusicStoreContext> options)
|
||||
: base(options)
|
||||
{
|
||||
}
|
||||
|
||||
public DbSet<Album> Albums { get; set; }
|
||||
public DbSet<Artist> Artists { get; set; }
|
||||
public DbSet<Order> Orders { get; set; }
|
||||
|
|
|
|||
|
|
@ -42,16 +42,12 @@ namespace MusicStore
|
|||
// Add EF services to the services container
|
||||
if (useInMemoryStore)
|
||||
{
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseInMemoryDatabase());
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddEntityFramework()
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseSqlServer(Configuration[StoreConfig.ConnectionStringKey.Replace("__",":")]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,7 @@ namespace MusicStore
|
|||
services.Configure<AppSettings>(Configuration.GetSection("AppSettings"));
|
||||
|
||||
// Add EF services to the services container
|
||||
services.AddEntityFramework()
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
|
||||
|
||||
// Add Identity services to the services container
|
||||
|
|
|
|||
|
|
@ -57,16 +57,12 @@ namespace MusicStore
|
|||
// Add EF services to the services container
|
||||
if (useInMemoryStore)
|
||||
{
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseInMemoryDatabase());
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddEntityFramework()
|
||||
.AddSqlServer()
|
||||
.AddDbContext<MusicStoreContext>(options =>
|
||||
services.AddDbContext<MusicStoreContext>(options =>
|
||||
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@ namespace MusicStore.Components
|
|||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
services.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,9 +23,7 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
services.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,9 +17,7 @@ namespace MusicStore.Components
|
|||
public GenreMenuComponentTest()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
services.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
services.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,9 +24,7 @@ namespace MusicStore.Controllers
|
|||
public ManageControllerTest()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
services.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
|
||||
services.AddIdentity<ApplicationUser, IdentityRole>()
|
||||
.AddEntityFrameworkStores<MusicStoreContext>();
|
||||
|
|
|
|||
|
|
@ -46,9 +46,7 @@ namespace MusicStore.Test
|
|||
public ShoppingCartFixture()
|
||||
{
|
||||
var services = new ServiceCollection();
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
services.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,9 +26,7 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
services.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
|
||||
services.AddMvc();
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,7 @@ namespace MusicStore.Controllers
|
|||
{
|
||||
var services = new ServiceCollection();
|
||||
|
||||
services.AddEntityFramework()
|
||||
.AddInMemoryDatabase()
|
||||
.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
services.AddDbContext<MusicStoreContext>(options => options.UseInMemoryDatabase());
|
||||
|
||||
_serviceProvider = services.BuildServiceProvider();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue