You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, in this video Mr. Shay Rojansky @roji introduced a way that gives us the ability to use Implicit Many to Many relationships besides the Join Entity,
I Wrote the navigation properties like that video,
and this my config in Fluent API
builder.Entity<ApplicationUser>().HasMany(appUser =>appUser.Roles).WithMany(role =>role.Users).UsingEntity<IdentityUserRole<int>>(au =>au.HasOne<ApplicationRole>().WithMany(role =>role.UserRoles),
au =>au.HasOne<ApplicationUser>().WithMany(user =>user.UserRoles));
but after creating a migration, the AspNetUserRoles has 4 properties.
migrationBuilder.CreateTable(name:"UserRoles",columns: table =>new{UserId=table.Column<int>(type:"int",nullable:false),RoleId=table.Column<int>(type:"int",nullable:false),RolesId=table.Column<int>(type:"int",nullable:true),UsersId=table.Column<int>(type:"int",nullable:true)},constraints: table =>{table.PrimaryKey("PK_UserRoles", x =>new{x.UserId,x.RoleId});table.ForeignKey(name:"FK_UserRoles_Roles_RoleId",column: x =>x.RoleId,principalTable:"Roles",principalColumn:"Id",onDelete:ReferentialAction.Cascade);table.ForeignKey(name:"FK_UserRoles_Roles_RolesId",column: x =>x.RolesId,principalTable:"Roles",principalColumn:"Id",onDelete:ReferentialAction.Restrict);table.ForeignKey(name:"FK_UserRoles_Users_UserId",column: x =>x.UserId,principalTable:"Users",principalColumn:"Id",onDelete:ReferentialAction.Cascade);table.ForeignKey(name:"FK_UserRoles_Users_UsersId",column: x =>x.UsersId,principalTable:"Users",principalColumn:"Id",onDelete:ReferentialAction.Restrict);});
How should I Write a correct configuration for achieving that feature in the video?
EF Core version:
Database provider: ( Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (.NET 5.0.2)
Operating system:
IDE: ( Visual Studio 2019 16.8.4)
The text was updated successfully, but these errors were encountered:
Hello, in this video Mr. Shay Rojansky @roji introduced a way that gives us the ability to use Implicit Many to Many relationships besides the Join Entity,
here is the link to that video: https://youtu.be/BIImyq8qaD4?t=1038
now I want to make this happen for IdentityUser and IdentityRole because I want to query roles and users easily with my context class.
I Wrote the navigation properties like that video,
and this my config in Fluent API
but after creating a migration, the AspNetUserRoles has 4 properties.
How should I Write a correct configuration for achieving that feature in the video?
EF Core version:
Database provider: ( Microsoft.EntityFrameworkCore.SqlServer)
Target framework: (.NET 5.0.2)
Operating system:
IDE: ( Visual Studio 2019 16.8.4)
The text was updated successfully, but these errors were encountered: