Update to dotnet 9.0, add user roles, MatchStats and OpenApi/Scalar in dev
This commit is contained in:
@@ -9,6 +9,7 @@ namespace LaDOSE.Entity.Context
|
||||
{
|
||||
public DbSet<Game> Game { get; set; }
|
||||
public DbSet<ApplicationUser> ApplicationUser { get; set; }
|
||||
public DbSet<ApplicationRole> ApplicationRole { get; set; }
|
||||
|
||||
public DbSet<Todo> Todo { get; set; }
|
||||
|
||||
@@ -49,6 +50,27 @@ namespace LaDOSE.Entity.Context
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
|
||||
#region Users and roles
|
||||
|
||||
// Maps onto the applicationrole / applicationuserrole tables that already exist
|
||||
// in the schema. The join table is configured explicitly rather than as a
|
||||
// many-to-many skip navigation so its columns are exactly userid + roleid,
|
||||
// with the pair as the key and no surrogate id.
|
||||
modelBuilder.Entity<ApplicationUserRole>(join =>
|
||||
{
|
||||
join.HasKey(ur => new { ur.UserId, ur.RoleId });
|
||||
|
||||
join.HasOne(ur => ur.User)
|
||||
.WithMany(u => u.UserRoles)
|
||||
.HasForeignKey(ur => ur.UserId);
|
||||
|
||||
join.HasOne(ur => ur.Role)
|
||||
.WithMany()
|
||||
.HasForeignKey(ur => ur.RoleId);
|
||||
});
|
||||
|
||||
#endregion
|
||||
|
||||
modelBuilder.Entity<Event>()
|
||||
.HasMany(s => s.Tournaments);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user