Updating AddEntityFramework call to not use nested closure.

This commit is contained in:
ajcvickers 2014-05-08 16:02:23 -07:00
parent 990481e48e
commit e9106fdfa9
4 changed files with 22 additions and 19 deletions

View File

@ -44,9 +44,9 @@ namespace Microsoft.AspNet.Identity.Entity.Test
{ {
var services = new ServiceCollection(); var services = new ServiceCollection();
#if NET45 #if NET45
// services.AddEntityFramework(s => s.AddSqlServer()); // services.AddEntityFramework().AddSqlServer();
//#else //#else
services.AddEntityFramework(s => s.AddInMemoryStore()); services.AddEntityFramework().AddInMemoryStore();
#endif #endif
services.AddSingleton<IOptionsAccessor<IdentityOptions>, OptionsAccessor<IdentityOptions>>(); services.AddSingleton<IOptionsAccessor<IdentityOptions>, OptionsAccessor<IdentityOptions>>();
services.AddInstance<DbContext>(new IdentityContext()); services.AddInstance<DbContext>(new IdentityContext());
@ -63,9 +63,9 @@ namespace Microsoft.AspNet.Identity.Entity.Test
{ {
var services = new ServiceCollection(); var services = new ServiceCollection();
#if NET45 #if NET45
// services.AddEntityFramework(s => s.AddSqlServer()); // services.AddEntityFramework().AddSqlServer();
//#else //#else
services.AddEntityFramework(s => s.AddInMemoryStore()); services.AddEntityFramework().AddInMemoryStore();
#endif #endif
// TODO: this needs to construct a new instance of InMemoryStore // TODO: this needs to construct a new instance of InMemoryStore
var store = new InMemoryInMemoryUserStore(new IdentityContext()); var store = new InMemoryInMemoryUserStore(new IdentityContext());
@ -205,7 +205,9 @@ namespace Microsoft.AspNet.Identity.Entity.Test
{ {
// TODO: Should be possible to do this without creating the provider externally, but // TODO: Should be possible to do this without creating the provider externally, but
// that is currently not working. Will be investigated. // that is currently not working. Will be investigated.
var provider = new ServiceCollection().AddEntityFramework(s => s.AddInMemoryStore()).BuildServiceProvider(); var services = new ServiceCollection();
services.AddEntityFramework().AddInMemoryStore();
var provider = services.BuildServiceProvider();
using (var db = new IdentityContext(provider)) using (var db = new IdentityContext(provider))
{ {

View File

@ -38,9 +38,9 @@ namespace Microsoft.AspNet.Identity.Entity.Test
{ {
var services = new ServiceCollection(); var services = new ServiceCollection();
#if NET45 #if NET45
// services.AddEntityFramework(s => s.AddSqlServer()); // services.AddEntityFramework().AddSqlServer();
//#else //#else
services.AddEntityFramework(s => s.AddInMemoryStore()); services.AddEntityFramework().AddInMemoryStore();
#endif #endif
// TODO: this should construct a new instance of InMemoryStore // TODO: this should construct a new instance of InMemoryStore
var store = new EntityRoleStore<EntityRole>(new IdentityContext()); var store = new EntityRoleStore<EntityRole>(new IdentityContext());
@ -60,9 +60,9 @@ namespace Microsoft.AspNet.Identity.Entity.Test
{ {
var services = new ServiceCollection(); var services = new ServiceCollection();
#if NET45 #if NET45
// services.AddEntityFramework(s => s.AddSqlServer()); // services.AddEntityFramework().AddSqlServer())
//#else //#else
services.AddEntityFramework(s => s.AddInMemoryStore()); services.AddEntityFramework().AddInMemoryStore();
#endif #endif
services.AddTransient<DbContext, IdentityContext>(); services.AddTransient<DbContext, IdentityContext>();
services.AddTransient<IRoleStore<EntityRole>, EntityRoleStore<EntityRole>>(); services.AddTransient<IRoleStore<EntityRole>, EntityRoleStore<EntityRole>>();

View File

@ -97,9 +97,9 @@ namespace Microsoft.AspNet.Identity.Entity.Test
public static IdentitySqlContext CreateContext() public static IdentitySqlContext CreateContext()
{ {
var serviceProvider = new ServiceCollection() var services = new ServiceCollection();
.AddEntityFramework(s => s.AddSqlServer()) services.AddEntityFramework().AddSqlServer();
.BuildServiceProvider(); var services.BuildServiceProvider();
var db = new IdentitySqlContext(serviceProvider); var db = new IdentitySqlContext(serviceProvider);
@ -115,9 +115,9 @@ namespace Microsoft.AspNet.Identity.Entity.Test
public static ApplicationDbContext CreateAppContext() public static ApplicationDbContext CreateAppContext()
{ {
var serviceProvider = new ServiceCollection() var services = new ServiceCollection();
.AddEntityFramework(s => s.AddSqlServer()) services.AddEntityFramework().AddSqlServer();
.BuildServiceProvider(); var serviceProvider = services.BuildServiceProvider();
var db = new ApplicationDbContext(serviceProvider); var db = new ApplicationDbContext(serviceProvider);

View File

@ -35,13 +35,14 @@ namespace Microsoft.AspNet.Identity.Entity.Test
{ {
public static IdentityContext CreateContext() public static IdentityContext CreateContext()
{ {
var serviceProvider = new ServiceCollection() var services = new ServiceCollection();
//#if NET45 //#if NET45
// .AddEntityFramework(s => s.AddSqlServer()) // services.AddEntityFramework().AddSqlServer();
//#else //#else
.AddEntityFramework(s => s.AddInMemoryStore()) services.AddEntityFramework().AddInMemoryStore();
//#endif //#endif
.BuildServiceProvider(); var serviceProvider = services.BuildServiceProvider();
var db = new IdentityContext(serviceProvider); var db = new IdentityContext(serviceProvider);