Updating EntitySet/EntityContext to DbSet/DbContext
This commit is contained in:
parent
9704cbc5ab
commit
ab1af578dd
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Identity.Entity
|
||||||
public IdentityContext(IServiceProvider serviceProvider) : base(serviceProvider) { }
|
public IdentityContext(IServiceProvider serviceProvider) : base(serviceProvider) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IdentityContext<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim> : EntityContext
|
public class IdentityContext<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim> : DbContext
|
||||||
where TUser : EntityUser<TKey, TUserLogin, TUserRole, TUserClaim>
|
where TUser : EntityUser<TKey, TUserLogin, TUserRole, TUserClaim>
|
||||||
where TRole : EntityRole<TKey, TUserRole> /*, TUserRole*/
|
where TRole : EntityRole<TKey, TUserRole> /*, TUserRole*/
|
||||||
where TUserLogin : IdentityUserLogin<TKey>
|
where TUserLogin : IdentityUserLogin<TKey>
|
||||||
|
|
@ -23,8 +23,8 @@ namespace Microsoft.AspNet.Identity.Entity
|
||||||
where TKey : IEquatable<TKey>
|
where TKey : IEquatable<TKey>
|
||||||
{
|
{
|
||||||
|
|
||||||
public EntitySet<TUser> Users { get; set; }
|
public DbSet<TUser> Users { get; set; }
|
||||||
public EntitySet<TRole> Roles { get; set; }
|
public DbSet<TRole> Roles { get; set; }
|
||||||
|
|
||||||
public IdentityContext(IServiceProvider serviceProvider)
|
public IdentityContext(IServiceProvider serviceProvider)
|
||||||
: base(serviceProvider) { }
|
: base(serviceProvider) { }
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ namespace Microsoft.AspNet.Identity.Entity
|
||||||
{
|
{
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public RoleStore(EntityContext context)
|
public RoleStore(DbContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
{
|
{
|
||||||
|
|
@ -24,7 +24,7 @@ namespace Microsoft.AspNet.Identity.Entity
|
||||||
AutoSaveChanges = true;
|
AutoSaveChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityContext Context { get; private set; }
|
public DbContext Context { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
|
/// If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,12 @@ namespace Microsoft.AspNet.Identity.Entity
|
||||||
public class UserStore :
|
public class UserStore :
|
||||||
UserStore<EntityUser>
|
UserStore<EntityUser>
|
||||||
{
|
{
|
||||||
public UserStore(EntityContext context) : base(context) { }
|
public UserStore(DbContext context) : base(context) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserStore<TUser> : UserStore<TUser, EntityRole, string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim> where TUser:EntityUser
|
public class UserStore<TUser> : UserStore<TUser, EntityRole, string, IdentityUserLogin, IdentityUserRole, IdentityUserClaim> where TUser:EntityUser
|
||||||
{
|
{
|
||||||
public UserStore(EntityContext context) : base(context) { }
|
public UserStore(DbContext context) : base(context) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UserStore<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim> :
|
public class UserStore<TUser, TRole, TKey, TUserLogin, TUserRole, TUserClaim> :
|
||||||
|
|
@ -41,7 +41,7 @@ namespace Microsoft.AspNet.Identity.Entity
|
||||||
{
|
{
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
public UserStore(EntityContext context)
|
public UserStore(DbContext context)
|
||||||
{
|
{
|
||||||
if (context == null)
|
if (context == null)
|
||||||
{
|
{
|
||||||
|
|
@ -51,7 +51,7 @@ namespace Microsoft.AspNet.Identity.Entity
|
||||||
AutoSaveChanges = true;
|
AutoSaveChanges = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityContext Context { get; private set; }
|
public DbContext Context { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
|
/// If true will call SaveChanges after CreateAsync/UpdateAsync/DeleteAsync
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Microsoft.AspNet.Identity.Entity.Test
|
||||||
{
|
{
|
||||||
public static class TestIdentityFactory
|
public static class TestIdentityFactory
|
||||||
{
|
{
|
||||||
public static EntityContext CreateContext()
|
public static DbContext CreateContext()
|
||||||
{
|
{
|
||||||
var serviceProvider = new ServiceCollection()
|
var serviceProvider = new ServiceCollection()
|
||||||
.AddEntityFramework(s => s.AddInMemoryStore())
|
.AddEntityFramework(s => s.AddInMemoryStore())
|
||||||
|
|
@ -79,7 +79,7 @@ namespace Microsoft.AspNet.Identity.Entity.Test
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static UserManager<EntityUser> CreateManager(EntityContext context)
|
public static UserManager<EntityUser> CreateManager(DbContext context)
|
||||||
{
|
{
|
||||||
var manager = new UserManager<EntityUser>(new UserStore(context))
|
var manager = new UserManager<EntityUser>(new UserStore(context))
|
||||||
{
|
{
|
||||||
|
|
@ -94,7 +94,7 @@ namespace Microsoft.AspNet.Identity.Entity.Test
|
||||||
return CreateManager(CreateContext());
|
return CreateManager(CreateContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static RoleManager<EntityRole> CreateRoleManager(EntityContext context)
|
public static RoleManager<EntityRole> CreateRoleManager(DbContext context)
|
||||||
{
|
{
|
||||||
return new RoleManager<EntityRole>(new RoleStore<EntityRole, string>(context));
|
return new RoleManager<EntityRole>(new RoleStore<EntityRole, string>(context));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -203,9 +203,9 @@ namespace Microsoft.AspNet.Identity.Entity.Test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SimpleContext : EntityContext
|
private class SimpleContext : DbContext
|
||||||
{
|
{
|
||||||
public EntitySet<Artist> Artists { get; set; }
|
public DbSet<Artist> Artists { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(EntityConfigurationBuilder builder)
|
protected override void OnConfiguring(EntityConfigurationBuilder builder)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue