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