created migrations and worked on identity module #17.

pull/81/head
Halil İbrahim Kalkan 9 years ago
parent 4c53e6ab67
commit c5ef0c08b6

@ -5,11 +5,15 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Identity.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace AbpDesk.ConsoleDemo
{
[DependsOn(typeof(AbpDeskApplicationModule), typeof(AbpDeskEntityFrameworkCoreModule))]
[DependsOn(
typeof(AbpDeskApplicationModule),
typeof(AbpDeskEntityFrameworkCoreModule),
typeof(AbpIdentityEntityFrameworkCoreModule))]
public class AbpDeskConsoleDemoModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)

@ -17,6 +17,11 @@ namespace AbpDesk.ConsoleDemo
.ServiceProvider
.GetRequiredService<TicketLister>()
.List();
//application
// .ServiceProvider
// .GetRequiredService<UserLister>()
// .List();
Console.ReadLine();

@ -0,0 +1,25 @@
using System;
using System.Linq;
using Volo.Abp.Identity;
using Volo.DependencyInjection;
namespace AbpDesk.ConsoleDemo
{
public class UserLister : ITransientDependency
{
private readonly IdentityUserManager _userManager;
public UserLister(IdentityUserManager userManager)
{
_userManager = userManager;
}
public void List()
{
foreach (var user in _userManager.Users.ToList())
{
Console.WriteLine(user);
}
}
}
}

@ -20,7 +20,9 @@
"version": "1.1.0-preview4-final"
},
"Microsoft.Extensions.Configuration.Json": "1.1.0",
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0"
"Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
"Volo.Abp.Identity": "1.0.0-*",
"Volo.Abp.Identity.EntityFrameworkCore": "1.0.0-*"
},
"tools": {

@ -0,0 +1,242 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Volo.Abp.Identity.EntityFrameworkCore;
namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
{
[DbContext(typeof(IdentityDbContext))]
[Migration("20161221194225_AbpIdentity_Initial_Migration")]
partial class AbpIdentity_Initial_Migration
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.1.0-rtm-22752")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("IdentityRoles");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("IdentityRoleClaims");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("IdentityUsers");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("IdentityUserClaims");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("LoginProvider");
b.Property<string>("ProviderDisplayName");
b.Property<string>("ProviderKey");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId", "LoginProvider", "ProviderKey")
.IsUnique();
b.ToTable("IdentityUserLogins");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("RoleId")
.IsRequired();
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.HasIndex("UserId", "RoleId")
.IsUnique();
b.ToTable("IdentityUserRoles");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<string>("Value");
b.HasKey("Id");
b.HasIndex("UserId", "LoginProvider", "Name")
.IsUnique();
b.ToTable("IdentityUserTokens");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole")
.WithMany("Claims")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Claims")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Logins")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Roles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Tokens")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
}
}
}

@ -0,0 +1,232 @@
using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Migrations;
namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
{
public partial class AbpIdentity_Initial_Migration : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "IdentityRoles",
columns: table => new
{
Id = table.Column<string>(nullable: false),
ConcurrencyStamp = table.Column<string>(nullable: true),
Name = table.Column<string>(maxLength: 256, nullable: true),
NormalizedName = table.Column<string>(maxLength: 256, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityRoles", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IdentityUsers",
columns: table => new
{
Id = table.Column<string>(nullable: false),
AccessFailedCount = table.Column<int>(nullable: false, defaultValue: 0),
ConcurrencyStamp = table.Column<string>(nullable: true),
Email = table.Column<string>(maxLength: 256, nullable: true),
EmailConfirmed = table.Column<bool>(nullable: false, defaultValue: false),
LockoutEnabled = table.Column<bool>(nullable: false, defaultValue: false),
LockoutEnd = table.Column<DateTimeOffset>(nullable: true),
NormalizedEmail = table.Column<string>(maxLength: 256, nullable: true),
NormalizedUserName = table.Column<string>(maxLength: 256, nullable: true),
PasswordHash = table.Column<string>(nullable: true),
PhoneNumber = table.Column<string>(nullable: true),
PhoneNumberConfirmed = table.Column<bool>(nullable: false, defaultValue: false),
SecurityStamp = table.Column<string>(nullable: true),
TwoFactorEnabled = table.Column<bool>(nullable: false, defaultValue: false),
UserName = table.Column<string>(maxLength: 256, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityUsers", x => x.Id);
});
migrationBuilder.CreateTable(
name: "IdentityRoleClaims",
columns: table => new
{
Id = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true),
RoleId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityRoleClaims", x => x.Id);
table.ForeignKey(
name: "FK_IdentityRoleClaims_IdentityRoles_RoleId",
column: x => x.RoleId,
principalTable: "IdentityRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityUserClaims",
columns: table => new
{
Id = table.Column<string>(nullable: false),
ClaimType = table.Column<string>(nullable: true),
ClaimValue = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityUserClaims", x => x.Id);
table.ForeignKey(
name: "FK_IdentityUserClaims_IdentityUsers_UserId",
column: x => x.UserId,
principalTable: "IdentityUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityUserLogins",
columns: table => new
{
Id = table.Column<string>(nullable: false),
LoginProvider = table.Column<string>(nullable: true),
ProviderDisplayName = table.Column<string>(nullable: true),
ProviderKey = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityUserLogins", x => x.Id);
table.ForeignKey(
name: "FK_IdentityUserLogins_IdentityUsers_UserId",
column: x => x.UserId,
principalTable: "IdentityUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityUserRoles",
columns: table => new
{
Id = table.Column<string>(nullable: false),
RoleId = table.Column<string>(nullable: false),
UserId = table.Column<string>(nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityUserRoles", x => x.Id);
table.ForeignKey(
name: "FK_IdentityUserRoles_IdentityRoles_RoleId",
column: x => x.RoleId,
principalTable: "IdentityRoles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_IdentityUserRoles_IdentityUsers_UserId",
column: x => x.UserId,
principalTable: "IdentityUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "IdentityUserTokens",
columns: table => new
{
Id = table.Column<string>(nullable: false),
LoginProvider = table.Column<string>(nullable: true),
Name = table.Column<string>(nullable: true),
UserId = table.Column<string>(nullable: false),
Value = table.Column<string>(nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_IdentityUserTokens", x => x.Id);
table.ForeignKey(
name: "FK_IdentityUserTokens_IdentityUsers_UserId",
column: x => x.UserId,
principalTable: "IdentityUsers",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "RoleNameIndex",
table: "IdentityRoles",
column: "NormalizedName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_IdentityRoleClaims_RoleId",
table: "IdentityRoleClaims",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "EmailIndex",
table: "IdentityUsers",
column: "NormalizedEmail");
migrationBuilder.CreateIndex(
name: "UserNameIndex",
table: "IdentityUsers",
column: "NormalizedUserName",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_IdentityUserClaims_UserId",
table: "IdentityUserClaims",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_IdentityUserLogins_UserId_LoginProvider_ProviderKey",
table: "IdentityUserLogins",
columns: new[] { "UserId", "LoginProvider", "ProviderKey" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_IdentityUserRoles_RoleId",
table: "IdentityUserRoles",
column: "RoleId");
migrationBuilder.CreateIndex(
name: "IX_IdentityUserRoles_UserId_RoleId",
table: "IdentityUserRoles",
columns: new[] { "UserId", "RoleId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_IdentityUserTokens_UserId_LoginProvider_Name",
table: "IdentityUserTokens",
columns: new[] { "UserId", "LoginProvider", "Name" },
unique: true);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "IdentityRoleClaims");
migrationBuilder.DropTable(
name: "IdentityUserClaims");
migrationBuilder.DropTable(
name: "IdentityUserLogins");
migrationBuilder.DropTable(
name: "IdentityUserRoles");
migrationBuilder.DropTable(
name: "IdentityUserTokens");
migrationBuilder.DropTable(
name: "IdentityRoles");
migrationBuilder.DropTable(
name: "IdentityUsers");
}
}
}

@ -0,0 +1,241 @@
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Volo.Abp.Identity.EntityFrameworkCore;
namespace Volo.Abp.Identity.EntityFrameworkCore.Migrations
{
[DbContext(typeof(IdentityDbContext))]
partial class IdentityDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
modelBuilder
.HasAnnotation("ProductVersion", "1.1.0-rtm-22752")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("Volo.Abp.Identity.IdentityRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Name")
.HasMaxLength(256);
b.Property<string>("NormalizedName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedName")
.IsUnique()
.HasName("RoleNameIndex");
b.ToTable("IdentityRoles");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("RoleId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.ToTable("IdentityRoleClaims");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUser", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<int>("AccessFailedCount");
b.Property<string>("ConcurrencyStamp")
.IsConcurrencyToken();
b.Property<string>("Email")
.HasMaxLength(256);
b.Property<bool>("EmailConfirmed");
b.Property<bool>("LockoutEnabled");
b.Property<DateTimeOffset?>("LockoutEnd");
b.Property<string>("NormalizedEmail")
.HasMaxLength(256);
b.Property<string>("NormalizedUserName")
.HasMaxLength(256);
b.Property<string>("PasswordHash");
b.Property<string>("PhoneNumber");
b.Property<bool>("PhoneNumberConfirmed");
b.Property<string>("SecurityStamp");
b.Property<bool>("TwoFactorEnabled");
b.Property<string>("UserName")
.HasMaxLength(256);
b.HasKey("Id");
b.HasIndex("NormalizedEmail")
.HasName("EmailIndex");
b.HasIndex("NormalizedUserName")
.IsUnique()
.HasName("UserNameIndex");
b.ToTable("IdentityUsers");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("ClaimType");
b.Property<string>("ClaimValue");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId");
b.ToTable("IdentityUserClaims");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("LoginProvider");
b.Property<string>("ProviderDisplayName");
b.Property<string>("ProviderKey");
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("UserId", "LoginProvider", "ProviderKey")
.IsUnique();
b.ToTable("IdentityUserLogins");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("RoleId")
.IsRequired();
b.Property<string>("UserId")
.IsRequired();
b.HasKey("Id");
b.HasIndex("RoleId");
b.HasIndex("UserId", "RoleId")
.IsUnique();
b.ToTable("IdentityUserRoles");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b =>
{
b.Property<string>("Id")
.ValueGeneratedOnAdd();
b.Property<string>("LoginProvider");
b.Property<string>("Name");
b.Property<string>("UserId")
.IsRequired();
b.Property<string>("Value");
b.HasKey("Id");
b.HasIndex("UserId", "LoginProvider", "Name")
.IsUnique();
b.ToTable("IdentityUserTokens");
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityRoleClaim", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole")
.WithMany("Claims")
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserClaim", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Claims")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserLogin", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Logins")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserRole", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityRole")
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade);
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Roles")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
modelBuilder.Entity("Volo.Abp.Identity.IdentityUserToken", b =>
{
b.HasOne("Volo.Abp.Identity.IdentityUser")
.WithMany("Tokens")
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade);
});
}
}
}

@ -0,0 +1,18 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Volo.Abp.Identity.EntityFrameworkCore;
namespace AbpDesk.EntityFrameworkCore
{
/* This class is needed for EF Core command line tooling */
public class IdentityDefaultDbContextFactory : IDbContextFactory<IdentityDbContext>
{
public IdentityDbContext Create(DbContextFactoryOptions options)
{
var builder = new DbContextOptionsBuilder<IdentityDbContext>();
builder.UseSqlServer("Server=localhost;Database=AbpDesk;Trusted_Connection=True;");
return new IdentityDbContext(builder.Options);
}
}
}

@ -0,0 +1,17 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.Modularity;
namespace Volo.Abp.Identity.EntityFrameworkCore
{
[DependsOn(typeof(AbpIdentityModule), typeof(AbpEntityFrameworkCoreModule))]
public class AbpIdentityEntityFrameworkCoreModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddAbpDbContext<IdentityDbContext>();
services.AddDefaultEfCoreRepositories<IdentityDbContext>(); //TODO: Move this into AddAbpDbContext as optional which will have it's own options
services.AddAssemblyOf<AbpIdentityEntityFrameworkCoreModule>();
}
}
}

@ -12,9 +12,11 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
/// 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)
public IdentityDbContext(DbContextOptions<IdentityDbContext> options)
: base(options)
{ }
{
}
/// <summary>
/// Gets or sets the <see cref="DbSet{TEntity}"/> of Users.
@ -59,6 +61,8 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
/// </param>
protected override void OnModelCreating(ModelBuilder builder)
{
//TODO: Set Default Values for properties
builder.Entity<IdentityUser>(b =>
{
b.ToTable("IdentityUsers");
@ -72,6 +76,7 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
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.HasMany(u => u.Tokens).WithOne().HasForeignKey(ur => ur.UserId).IsRequired();
b.HasIndex(u => u.NormalizedUserName).HasName("UserNameIndex").IsUnique();
b.HasIndex(u => u.NormalizedEmail).HasName("EmailIndex");
@ -95,23 +100,19 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
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.HasOne<IdentityRole>().WithMany().HasForeignKey(ur => ur.RoleId).IsRequired();
b.HasIndex(r => new { r.UserId, r.RoleId }).IsUnique();
});
@ -120,15 +121,13 @@ namespace Volo.Abp.Identity.EntityFrameworkCore
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?
b.HasIndex(l => new { l.UserId, l.LoginProvider, l.Name }).IsUnique();
});
}
}

@ -5,6 +5,7 @@
"NETStandard.Library": "1.6.1",
"Volo.Abp.EntityFrameworkCore": "1.0.0-*",
"Microsoft.EntityFrameworkCore.Relational": "1.1.0",
"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
"Volo.Abp.Identity": "1.0.0-*"
},

@ -0,0 +1,13 @@
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace Volo.Abp.Identity
{
public class AbpIdentityModule : AbpModule
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddAssemblyOf<AbpIdentityModule>();
}
}
}

@ -2,10 +2,11 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Volo.Abp.Domain.Services;
namespace Volo.Abp.Identity
{
public class IdentityRoleManager : RoleManager<IdentityRole>
public class IdentityRoleManager : RoleManager<IdentityRole>, IDomainService
{
public IdentityRoleManager(
IRoleStore<IdentityRole> store,

@ -103,6 +103,11 @@ namespace Volo.Abp.Identity
/// </summary>
public virtual ICollection<IdentityUserLogin> Logins { get; } = new Collection<IdentityUserLogin>();
/// <summary>
/// Navigation property for this users tokens.
/// </summary>
public virtual ICollection<IdentityUserToken> Tokens { get; } = new Collection<IdentityUserToken>();
protected IdentityUser()
{

@ -4,10 +4,11 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Volo.Abp.Domain.Services;
namespace Volo.Abp.Identity
{
public class IdentityUserManager : UserManager<IdentityUser>
public class IdentityUserManager : UserManager<IdentityUser>, IDomainService
{
public IdentityUserManager(
IUserStore<IdentityUser> store,

@ -0,0 +1,12 @@
using Volo.DependencyInjection;
namespace Volo.Abp.Domain.Services
{
/// <summary>
/// This interface must be implemented by all domain services to identify them by convention.
/// </summary>
public interface IDomainService : ITransientDependency
{
}
}
Loading…
Cancel
Save