mirror of https://github.com/abpframework/abp.git
5 changed files with 197 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||||
|
using System.Reflection; |
||||
|
using System.Runtime.CompilerServices; |
||||
|
using System.Runtime.InteropServices; |
||||
|
|
||||
|
// General Information about an assembly is controlled through the following
|
||||
|
// set of attributes. Change these attribute values to modify the information
|
||||
|
// associated with an assembly.
|
||||
|
[assembly: AssemblyConfiguration("")] |
||||
|
[assembly: AssemblyCompany("")] |
||||
|
[assembly: AssemblyProduct("Volo.Abp.Identity.EntityFrameworkCore")] |
||||
|
[assembly: AssemblyTrademark("")] |
||||
|
|
||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
|
// to COM components. If you need to access a type in this assembly from
|
||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||
|
[assembly: ComVisible(false)] |
||||
|
|
||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
|
[assembly: Guid("439dfc0f-1ba2-464f-900e-ea7e18c08975")] |
||||
@ -0,0 +1,20 @@ |
|||||
|
<?xml version="1.0" encoding="utf-8"?> |
||||
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> |
||||
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
<PropertyGroup Label="Globals"> |
||||
|
<ProjectGuid>439dfc0f-1ba2-464f-900e-ea7e18c08975</ProjectGuid> |
||||
|
<RootNamespace> |
||||
|
</RootNamespace> |
||||
|
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> |
||||
|
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> |
||||
|
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> |
||||
|
</PropertyGroup> |
||||
|
<PropertyGroup> |
||||
|
<SchemaVersion>2.0</SchemaVersion> |
||||
|
</PropertyGroup> |
||||
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" /> |
||||
|
</Project> |
||||
@ -0,0 +1,135 @@ |
|||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Volo.Abp.EntityFrameworkCore; |
||||
|
|
||||
|
namespace Volo.Abp.Identity.EntityFrameworkCore |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Base class for the Entity Framework database context used for identity.
|
||||
|
/// </summary>
|
||||
|
public class IdentityDbContext : AbpDbContext<IdentityDbContext> |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Initializes a new instance of <see cref="IdentityDbContext"/>.
|
||||
|
/// </summary>
|
||||
|
/// <param name="options">The options to be used by a <see cref="DbContext"/>.</param>
|
||||
|
public IdentityDbContext(DbContextOptions<IdentityDbContext> options) |
||||
|
: base(options) |
||||
|
{ } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the <see cref="DbSet{TEntity}"/> of Users.
|
||||
|
/// </summary>
|
||||
|
public DbSet<IdentityUser> Users { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the <see cref="DbSet{TEntity}"/> of User claims.
|
||||
|
/// </summary>
|
||||
|
public DbSet<IdentityUserClaim> UserClaims { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the <see cref="DbSet{TEntity}"/> of User logins.
|
||||
|
/// </summary>
|
||||
|
public DbSet<IdentityUserLogin> UserLogins { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the <see cref="DbSet{TEntity}"/> of User roles.
|
||||
|
/// </summary>
|
||||
|
public DbSet<IdentityUserRole> UserRoles { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the <see cref="DbSet{TEntity}"/> of User tokens.
|
||||
|
/// </summary>
|
||||
|
public DbSet<IdentityUserToken> UserTokens { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the <see cref="DbSet{TEntity}"/> of roles.
|
||||
|
/// </summary>
|
||||
|
public DbSet<IdentityRole> Roles { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Gets or sets the <see cref="DbSet{TEntity}"/> of role claims.
|
||||
|
/// </summary>
|
||||
|
public DbSet<IdentityRoleClaim> RoleClaims { get; set; } |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Configures the schema needed for the identity framework.
|
||||
|
/// </summary>
|
||||
|
/// <param name="builder">
|
||||
|
/// The builder being used to construct the model for this context.
|
||||
|
/// </param>
|
||||
|
protected override void OnModelCreating(ModelBuilder builder) |
||||
|
{ |
||||
|
builder.Entity<IdentityUser>(b => |
||||
|
{ |
||||
|
b.ToTable("IdentityUsers"); |
||||
|
|
||||
|
b.Property(u => u.ConcurrencyStamp).IsConcurrencyToken(); |
||||
|
b.Property(u => u.UserName).HasMaxLength(256); |
||||
|
b.Property(u => u.NormalizedUserName).HasMaxLength(256); |
||||
|
b.Property(u => u.Email).HasMaxLength(256); |
||||
|
b.Property(u => u.NormalizedEmail).HasMaxLength(256); |
||||
|
|
||||
|
b.HasMany(u => u.Claims).WithOne().HasForeignKey(uc => uc.UserId).IsRequired(); |
||||
|
b.HasMany(u => u.Logins).WithOne().HasForeignKey(ul => ul.UserId).IsRequired(); |
||||
|
b.HasMany(u => u.Roles).WithOne().HasForeignKey(ur => ur.UserId).IsRequired(); |
||||
|
|
||||
|
b.HasIndex(u => u.NormalizedUserName).HasName("UserNameIndex").IsUnique(); |
||||
|
b.HasIndex(u => u.NormalizedEmail).HasName("EmailIndex"); |
||||
|
}); |
||||
|
|
||||
|
builder.Entity<IdentityRole>(b => |
||||
|
{ |
||||
|
b.ToTable("IdentityRoles"); |
||||
|
|
||||
|
b.Property(r => r.ConcurrencyStamp).IsConcurrencyToken(); |
||||
|
b.Property(u => u.Name).HasMaxLength(256); |
||||
|
b.Property(u => u.NormalizedName).HasMaxLength(256); |
||||
|
|
||||
|
//TODO: Relation & Foreign Key!
|
||||
|
//b.HasMany(r => r.Users).WithOne().HasForeignKey(ur => ur.RoleId).IsRequired();
|
||||
|
b.HasMany(r => r.Claims).WithOne().HasForeignKey(rc => rc.RoleId).IsRequired(); |
||||
|
|
||||
|
b.HasIndex(r => r.NormalizedName).HasName("RoleNameIndex").IsUnique(); |
||||
|
}); |
||||
|
|
||||
|
builder.Entity<IdentityUserClaim>(b => |
||||
|
{ |
||||
|
b.ToTable("IdentityUserClaims"); |
||||
|
|
||||
|
//TODO: Index?
|
||||
|
//TODO: Foreign Keys?
|
||||
|
}); |
||||
|
|
||||
|
builder.Entity<IdentityRoleClaim>(b => |
||||
|
{ |
||||
|
b.ToTable("IdentityRoleClaims"); |
||||
|
|
||||
|
//TODO: Index?
|
||||
|
//TODO: Foreign Keys?
|
||||
|
}); |
||||
|
|
||||
|
builder.Entity<IdentityUserRole>(b => |
||||
|
{ |
||||
|
b.ToTable("IdentityUserRoles"); |
||||
|
|
||||
|
b.HasIndex(r => new { r.UserId, r.RoleId }).IsUnique(); |
||||
|
}); |
||||
|
|
||||
|
builder.Entity<IdentityUserLogin>(b => |
||||
|
{ |
||||
|
b.ToTable("IdentityUserLogins"); |
||||
|
|
||||
|
b.HasIndex(l => new { l.UserId, l.LoginProvider, l.ProviderKey }).IsUnique(); |
||||
|
//TODO: Foreign Keys?
|
||||
|
}); |
||||
|
|
||||
|
builder.Entity<IdentityUserToken>(b => |
||||
|
{ |
||||
|
b.ToTable("IdentityUserTokens"); |
||||
|
|
||||
|
b.HasIndex(l => new {l.UserId, l.LoginProvider, l.Name}).IsUnique(); |
||||
|
//TODO: Foreign Keys?
|
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
{ |
||||
|
"version": "1.0.0-*", |
||||
|
|
||||
|
"dependencies": { |
||||
|
"NETStandard.Library": "1.6.1", |
||||
|
"Volo.Abp.EntityFrameworkCore": "1.0.0-*", |
||||
|
"Microsoft.EntityFrameworkCore.Relational": "1.1.0", |
||||
|
"Volo.Abp.Identity": "1.0.0-*" |
||||
|
}, |
||||
|
|
||||
|
"frameworks": { |
||||
|
"netstandard1.6": { |
||||
|
"imports": "dnxcore50" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue