Exemplo n.º 1
0
        private void ConfigureEntityUsersTable(DbModelBuilder modelBuilder, string discriminator)
        {
            var users = modelBuilder.Entity <IdentityUser>().ToTable(UtilAut.GetTableUsers(), UtilAut.GetSchema());

            users.Map <AppUser>(appUser => appUser.Requires(discriminator).HasValue("APPUSER"));
            users.HasMany(user => user.Roles).WithRequired().HasForeignKey(rUsers => rUsers.UserId);
            users.HasMany(user => user.Claims).WithRequired().HasForeignKey(uClaims => uClaims.UserId);
            users.HasMany(user => user.Logins).WithRequired().HasForeignKey(uLogins => uLogins.UserId);
        }
Exemplo n.º 2
0
        private void ConfigureEntitRolesTable(DbModelBuilder modelBuilder, string discriminator)
        {
            var roles = modelBuilder.Entity <IdentityRole>().ToTable(UtilAut.GetTableRoles(), UtilAut.GetSchema());

            roles.Map <AppRole>(appRole => appRole.Requires(discriminator).HasValue("APPROLE"));
            roles.HasMany(role => role.Users).WithRequired().HasForeignKey(uRol => uRol.RoleId);
        }
Exemplo n.º 3
0
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            var discriminator = "DISC";

            modelBuilder.Entity <IdentityUserRole>().ToTable(UtilAut.GetTableUserRoles(), UtilAut.GetSchema())
            .HasKey(userRole => new { userRole.UserId, userRole.RoleId });
            modelBuilder.Entity <IdentityUserLogin>().ToTable(UtilAut.GetTableLogins(), UtilAut.GetSchema())
            .HasKey(userLogin => new { userLogin.UserId, userLogin.ProviderKey, userLogin.LoginProvider });
            modelBuilder.Entity <IdentityUserClaim>().ToTable(UtilAut.GetTableClaims(), UtilAut.GetSchema());
            ConfigureEntityUsersTable(modelBuilder, discriminator);
            ConfigureEntitRolesTable(modelBuilder, discriminator);
        }