diff --git a/Data/DatabaseContext.cs b/Data/DatabaseContext.cs index 12e882a..6f37f13 100644 --- a/Data/DatabaseContext.cs +++ b/Data/DatabaseContext.cs @@ -1,10 +1,11 @@ using LANCommander.Data.Models; +using Microsoft.AspNetCore.Identity; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; using Microsoft.EntityFrameworkCore; namespace LANCommander.Data { - public class DatabaseContext : IdentityDbContext + public class DatabaseContext : IdentityDbContext, Guid> { public DatabaseContext(DbContextOptions options) : base(options) diff --git a/Data/Models/BaseModel.cs b/Data/Models/BaseModel.cs index 0c67783..8383c3f 100644 --- a/Data/Models/BaseModel.cs +++ b/Data/Models/BaseModel.cs @@ -1,4 +1,5 @@ using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; namespace LANCommander.Data.Models { @@ -8,8 +9,8 @@ namespace LANCommander.Data.Models public Guid Id { get; set; } public DateTime CreatedOn { get; set; } - public Guid CreatedById { get; set; } + public virtual User? CreatedBy { get; set; } public DateTime UpdatedOn { get; set; } - public Guid UpdatedById { get; set; } + public virtual User? UpdatedBy { get; set; } } } diff --git a/Data/Models/User.cs b/Data/Models/User.cs index fae9fab..4861c84 100644 --- a/Data/Models/User.cs +++ b/Data/Models/User.cs @@ -5,7 +5,7 @@ using System.ComponentModel.DataAnnotations.Schema; namespace LANCommander.Data.Models { [Table("Users")] - public class User : IdentityUser + public class User : IdentityUser { } } diff --git a/Data/Repository.cs b/Data/Repository.cs index d4dcfe1..09dad9f 100644 --- a/Data/Repository.cs +++ b/Data/Repository.cs @@ -42,8 +42,8 @@ namespace LANCommander.Data public async Task Add(T entity) { - entity.CreatedById = GetCurrentUserId(); - entity.UpdatedById = GetCurrentUserId(); + entity.CreatedBy = GetCurrentUser(); + entity.UpdatedBy = GetCurrentUser(); entity.CreatedOn = DateTime.Now; entity.UpdatedOn = DateTime.Now; @@ -54,7 +54,7 @@ namespace LANCommander.Data public T Update(T entity) { - entity.UpdatedById = GetCurrentUserId(); + entity.UpdatedBy = GetCurrentUser(); entity.UpdatedOn = DateTime.Now; Context.Update(entity); @@ -72,19 +72,19 @@ namespace LANCommander.Data return UserDbSet.FirstOrDefault(u => u.UserName == username); } - private Guid GetCurrentUserId() + private User GetCurrentUser() { if (HttpContext != null && HttpContext.User != null && HttpContext.User.Identity != null && HttpContext.User.Identity.IsAuthenticated) { var user = GetUser(HttpContext.User.Identity.Name); if (user == null) - return Guid.Empty; + return null; else - return Guid.Parse(user.Id); + return user; } else - return Guid.Empty; + return null; } public void Dispose() diff --git a/Migrations/20230103064847_RekeyUsers.Designer.cs b/Migrations/20230103064847_RekeyUsers.Designer.cs new file mode 100644 index 0000000..b3e8924 --- /dev/null +++ b/Migrations/20230103064847_RekeyUsers.Designer.cs @@ -0,0 +1,576 @@ +// +using System; +using LANCommander.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace LANCommander.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20230103064847_RekeyUsers")] + partial class RekeyUsers + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.8"); + + modelBuilder.Entity("GameTag", b => + { + b.Property("GamesId") + .HasColumnType("TEXT"); + + b.Property("TagsId") + .HasColumnType("TEXT"); + + b.HasKey("GamesId", "TagsId"); + + b.HasIndex("TagsId"); + + b.ToTable("GameTag"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Archive", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Changelog") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("GameId") + .HasColumnType("TEXT"); + + b.Property("LastVersionId") + .HasColumnType("TEXT"); + + b.Property("ObjectKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedById") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.Property("Version") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("GameId"); + + b.HasIndex("LastVersionId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Archive"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Company", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedById") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Companies"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Game", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DeveloperId") + .HasColumnType("TEXT"); + + b.Property("DirectoryName") + .HasColumnType("TEXT"); + + b.Property("PublisherId") + .HasColumnType("TEXT"); + + b.Property("ReleasedOn") + .HasColumnType("TEXT"); + + b.Property("SortTitle") + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedById") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("DeveloperId"); + + b.HasIndex("PublisherId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Games"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedById") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Tags"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("GameTag", b => + { + b.HasOne("LANCommander.Data.Models.Game", null) + .WithMany() + .HasForeignKey("GamesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LANCommander.Data.Models.Tag", null) + .WithMany() + .HasForeignKey("TagsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Archive", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LANCommander.Data.Models.Game", "Game") + .WithMany("Archives") + .HasForeignKey("GameId"); + + b.HasOne("LANCommander.Data.Models.Archive", "LastVersion") + .WithMany() + .HasForeignKey("LastVersionId"); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Game"); + + b.Navigation("LastVersion"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Company", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Game", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LANCommander.Data.Models.Company", "Developer") + .WithMany("DevelopedGames") + .HasForeignKey("DeveloperId"); + + b.HasOne("LANCommander.Data.Models.Company", "Publisher") + .WithMany("PublishedGames") + .HasForeignKey("PublisherId"); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("Developer"); + + b.Navigation("Publisher"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Tag", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("CreatedBy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("LANCommander.Data.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("LANCommander.Data.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LANCommander.Data.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("LANCommander.Data.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Company", b => + { + b.Navigation("DevelopedGames"); + + b.Navigation("PublishedGames"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Game", b => + { + b.Navigation("Archives"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20230103064847_RekeyUsers.cs b/Migrations/20230103064847_RekeyUsers.cs new file mode 100644 index 0000000..aaa0651 --- /dev/null +++ b/Migrations/20230103064847_RekeyUsers.cs @@ -0,0 +1,183 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LANCommander.Migrations +{ + public partial class RekeyUsers : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.CreateIndex( + name: "IX_Tags_CreatedById", + table: "Tags", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Tags_UpdatedById", + table: "Tags", + column: "UpdatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Games_CreatedById", + table: "Games", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Games_UpdatedById", + table: "Games", + column: "UpdatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Companies_CreatedById", + table: "Companies", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Companies_UpdatedById", + table: "Companies", + column: "UpdatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Archive_CreatedById", + table: "Archive", + column: "CreatedById"); + + migrationBuilder.CreateIndex( + name: "IX_Archive_UpdatedById", + table: "Archive", + column: "UpdatedById"); + + migrationBuilder.AddForeignKey( + name: "FK_Archive_AspNetUsers_CreatedById", + table: "Archive", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Archive_AspNetUsers_UpdatedById", + table: "Archive", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Companies_AspNetUsers_CreatedById", + table: "Companies", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Companies_AspNetUsers_UpdatedById", + table: "Companies", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Games_AspNetUsers_CreatedById", + table: "Games", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Games_AspNetUsers_UpdatedById", + table: "Games", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Tags_AspNetUsers_CreatedById", + table: "Tags", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Tags_AspNetUsers_UpdatedById", + table: "Tags", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Archive_AspNetUsers_CreatedById", + table: "Archive"); + + migrationBuilder.DropForeignKey( + name: "FK_Archive_AspNetUsers_UpdatedById", + table: "Archive"); + + migrationBuilder.DropForeignKey( + name: "FK_Companies_AspNetUsers_CreatedById", + table: "Companies"); + + migrationBuilder.DropForeignKey( + name: "FK_Companies_AspNetUsers_UpdatedById", + table: "Companies"); + + migrationBuilder.DropForeignKey( + name: "FK_Games_AspNetUsers_CreatedById", + table: "Games"); + + migrationBuilder.DropForeignKey( + name: "FK_Games_AspNetUsers_UpdatedById", + table: "Games"); + + migrationBuilder.DropForeignKey( + name: "FK_Tags_AspNetUsers_CreatedById", + table: "Tags"); + + migrationBuilder.DropForeignKey( + name: "FK_Tags_AspNetUsers_UpdatedById", + table: "Tags"); + + migrationBuilder.DropIndex( + name: "IX_Tags_CreatedById", + table: "Tags"); + + migrationBuilder.DropIndex( + name: "IX_Tags_UpdatedById", + table: "Tags"); + + migrationBuilder.DropIndex( + name: "IX_Games_CreatedById", + table: "Games"); + + migrationBuilder.DropIndex( + name: "IX_Games_UpdatedById", + table: "Games"); + + migrationBuilder.DropIndex( + name: "IX_Companies_CreatedById", + table: "Companies"); + + migrationBuilder.DropIndex( + name: "IX_Companies_UpdatedById", + table: "Companies"); + + migrationBuilder.DropIndex( + name: "IX_Archive_CreatedById", + table: "Archive"); + + migrationBuilder.DropIndex( + name: "IX_Archive_UpdatedById", + table: "Archive"); + } + } +} diff --git a/Migrations/20230103070011_SimplifyUserNavigation.Designer.cs b/Migrations/20230103070011_SimplifyUserNavigation.Designer.cs new file mode 100644 index 0000000..3934344 --- /dev/null +++ b/Migrations/20230103070011_SimplifyUserNavigation.Designer.cs @@ -0,0 +1,560 @@ +// +using System; +using LANCommander.Data; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; + +#nullable disable + +namespace LANCommander.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20230103070011_SimplifyUserNavigation")] + partial class SimplifyUserNavigation + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder.HasAnnotation("ProductVersion", "6.0.8"); + + modelBuilder.Entity("GameTag", b => + { + b.Property("GamesId") + .HasColumnType("TEXT"); + + b.Property("TagsId") + .HasColumnType("TEXT"); + + b.HasKey("GamesId", "TagsId"); + + b.HasIndex("TagsId"); + + b.ToTable("GameTag"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Archive", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("Changelog") + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("GameId") + .HasColumnType("TEXT"); + + b.Property("LastVersionId") + .HasColumnType("TEXT"); + + b.Property("ObjectKey") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedById") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.Property("Version") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("GameId"); + + b.HasIndex("LastVersionId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Archive"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Company", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedById") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Companies"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Game", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Description") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("DeveloperId") + .HasColumnType("TEXT"); + + b.Property("DirectoryName") + .HasColumnType("TEXT"); + + b.Property("PublisherId") + .HasColumnType("TEXT"); + + b.Property("ReleasedOn") + .HasColumnType("TEXT"); + + b.Property("SortTitle") + .HasColumnType("TEXT"); + + b.Property("Title") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedById") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("DeveloperId"); + + b.HasIndex("PublisherId"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Games"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Tag", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("CreatedById") + .HasColumnType("TEXT"); + + b.Property("CreatedOn") + .HasColumnType("TEXT"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("UpdatedById") + .HasColumnType("TEXT"); + + b.Property("UpdatedOn") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("CreatedById"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Tags"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.User", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("AccessFailedCount") + .HasColumnType("INTEGER"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Email") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("EmailConfirmed") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnabled") + .HasColumnType("INTEGER"); + + b.Property("LockoutEnd") + .HasColumnType("TEXT"); + + b.Property("NormalizedEmail") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedUserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("PasswordHash") + .HasColumnType("TEXT"); + + b.Property("PhoneNumber") + .HasColumnType("TEXT"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("INTEGER"); + + b.Property("SecurityStamp") + .HasColumnType("TEXT"); + + b.Property("TwoFactorEnabled") + .HasColumnType("INTEGER"); + + b.Property("UserName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedEmail") + .HasDatabaseName("EmailIndex"); + + b.HasIndex("NormalizedUserName") + .IsUnique() + .HasDatabaseName("UserNameIndex"); + + b.ToTable("AspNetUsers", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("TEXT"); + + b.Property("ConcurrencyStamp") + .IsConcurrencyToken() + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.Property("NormalizedName") + .HasMaxLength(256) + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("NormalizedName") + .IsUnique() + .HasDatabaseName("RoleNameIndex"); + + b.ToTable("AspNetRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetRoleClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.Property("Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("ClaimType") + .HasColumnType("TEXT"); + + b.Property("ClaimValue") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("Id"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserClaims", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ProviderKey") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("ProviderDisplayName") + .HasColumnType("TEXT"); + + b.Property("UserId") + .HasColumnType("TEXT"); + + b.HasKey("LoginProvider", "ProviderKey"); + + b.HasIndex("UserId"); + + b.ToTable("AspNetUserLogins", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("RoleId") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "RoleId"); + + b.HasIndex("RoleId"); + + b.ToTable("AspNetUserRoles", (string)null); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.Property("UserId") + .HasColumnType("TEXT"); + + b.Property("LoginProvider") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Name") + .HasMaxLength(128) + .HasColumnType("TEXT"); + + b.Property("Value") + .HasColumnType("TEXT"); + + b.HasKey("UserId", "LoginProvider", "Name"); + + b.ToTable("AspNetUserTokens", (string)null); + }); + + modelBuilder.Entity("GameTag", b => + { + b.HasOne("LANCommander.Data.Models.Game", null) + .WithMany() + .HasForeignKey("GamesId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LANCommander.Data.Models.Tag", null) + .WithMany() + .HasForeignKey("TagsId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Archive", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("LANCommander.Data.Models.Game", "Game") + .WithMany("Archives") + .HasForeignKey("GameId"); + + b.HasOne("LANCommander.Data.Models.Archive", "LastVersion") + .WithMany() + .HasForeignKey("LastVersionId"); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("Game"); + + b.Navigation("LastVersion"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Company", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Game", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("LANCommander.Data.Models.Company", "Developer") + .WithMany("DevelopedGames") + .HasForeignKey("DeveloperId"); + + b.HasOne("LANCommander.Data.Models.Company", "Publisher") + .WithMany("PublishedGames") + .HasForeignKey("PublisherId"); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("Developer"); + + b.Navigation("Publisher"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Tag", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + { + b.HasOne("LANCommander.Data.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + { + b.HasOne("LANCommander.Data.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + .WithMany() + .HasForeignKey("RoleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("LANCommander.Data.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + { + b.HasOne("LANCommander.Data.Models.User", null) + .WithMany() + .HasForeignKey("UserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Company", b => + { + b.Navigation("DevelopedGames"); + + b.Navigation("PublishedGames"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Game", b => + { + b.Navigation("Archives"); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/Migrations/20230103070011_SimplifyUserNavigation.cs b/Migrations/20230103070011_SimplifyUserNavigation.cs new file mode 100644 index 0000000..21095bc --- /dev/null +++ b/Migrations/20230103070011_SimplifyUserNavigation.cs @@ -0,0 +1,344 @@ +using System; +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace LANCommander.Migrations +{ + public partial class SimplifyUserNavigation : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Archive_AspNetUsers_CreatedById", + table: "Archive"); + + migrationBuilder.DropForeignKey( + name: "FK_Archive_AspNetUsers_UpdatedById", + table: "Archive"); + + migrationBuilder.DropForeignKey( + name: "FK_Companies_AspNetUsers_CreatedById", + table: "Companies"); + + migrationBuilder.DropForeignKey( + name: "FK_Companies_AspNetUsers_UpdatedById", + table: "Companies"); + + migrationBuilder.DropForeignKey( + name: "FK_Games_AspNetUsers_CreatedById", + table: "Games"); + + migrationBuilder.DropForeignKey( + name: "FK_Games_AspNetUsers_UpdatedById", + table: "Games"); + + migrationBuilder.DropForeignKey( + name: "FK_Tags_AspNetUsers_CreatedById", + table: "Tags"); + + migrationBuilder.DropForeignKey( + name: "FK_Tags_AspNetUsers_UpdatedById", + table: "Tags"); + + migrationBuilder.AlterColumn( + name: "UpdatedById", + table: "Tags", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "CreatedById", + table: "Tags", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "UpdatedById", + table: "Games", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "CreatedById", + table: "Games", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "UpdatedById", + table: "Companies", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "CreatedById", + table: "Companies", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "UpdatedById", + table: "Archive", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AlterColumn( + name: "CreatedById", + table: "Archive", + type: "TEXT", + nullable: true, + oldClrType: typeof(Guid), + oldType: "TEXT"); + + migrationBuilder.AddForeignKey( + name: "FK_Archive_AspNetUsers_CreatedById", + table: "Archive", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Archive_AspNetUsers_UpdatedById", + table: "Archive", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Companies_AspNetUsers_CreatedById", + table: "Companies", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Companies_AspNetUsers_UpdatedById", + table: "Companies", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Games_AspNetUsers_CreatedById", + table: "Games", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Games_AspNetUsers_UpdatedById", + table: "Games", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Tags_AspNetUsers_CreatedById", + table: "Tags", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Tags_AspNetUsers_UpdatedById", + table: "Tags", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Archive_AspNetUsers_CreatedById", + table: "Archive"); + + migrationBuilder.DropForeignKey( + name: "FK_Archive_AspNetUsers_UpdatedById", + table: "Archive"); + + migrationBuilder.DropForeignKey( + name: "FK_Companies_AspNetUsers_CreatedById", + table: "Companies"); + + migrationBuilder.DropForeignKey( + name: "FK_Companies_AspNetUsers_UpdatedById", + table: "Companies"); + + migrationBuilder.DropForeignKey( + name: "FK_Games_AspNetUsers_CreatedById", + table: "Games"); + + migrationBuilder.DropForeignKey( + name: "FK_Games_AspNetUsers_UpdatedById", + table: "Games"); + + migrationBuilder.DropForeignKey( + name: "FK_Tags_AspNetUsers_CreatedById", + table: "Tags"); + + migrationBuilder.DropForeignKey( + name: "FK_Tags_AspNetUsers_UpdatedById", + table: "Tags"); + + migrationBuilder.AlterColumn( + name: "UpdatedById", + table: "Tags", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedById", + table: "Tags", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedById", + table: "Games", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedById", + table: "Games", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedById", + table: "Companies", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedById", + table: "Companies", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "UpdatedById", + table: "Archive", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AlterColumn( + name: "CreatedById", + table: "Archive", + type: "TEXT", + nullable: false, + defaultValue: new Guid("00000000-0000-0000-0000-000000000000"), + oldClrType: typeof(Guid), + oldType: "TEXT", + oldNullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_Archive_AspNetUsers_CreatedById", + table: "Archive", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Archive_AspNetUsers_UpdatedById", + table: "Archive", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Companies_AspNetUsers_CreatedById", + table: "Companies", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Companies_AspNetUsers_UpdatedById", + table: "Companies", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Games_AspNetUsers_CreatedById", + table: "Games", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Games_AspNetUsers_UpdatedById", + table: "Games", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Tags_AspNetUsers_CreatedById", + table: "Tags", + column: "CreatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_Tags_AspNetUsers_UpdatedById", + table: "Tags", + column: "UpdatedById", + principalTable: "AspNetUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/Migrations/DatabaseContextModelSnapshot.cs b/Migrations/DatabaseContextModelSnapshot.cs index 7550f3f..e6e8053 100644 --- a/Migrations/DatabaseContextModelSnapshot.cs +++ b/Migrations/DatabaseContextModelSnapshot.cs @@ -29,7 +29,7 @@ namespace LANCommander.Migrations b.HasIndex("TagsId"); - b.ToTable("GameTag", (string)null); + b.ToTable("GameTag"); }); modelBuilder.Entity("LANCommander.Data.Models.Archive", b => @@ -41,7 +41,7 @@ namespace LANCommander.Migrations b.Property("Changelog") .HasColumnType("TEXT"); - b.Property("CreatedById") + b.Property("CreatedById") .HasColumnType("TEXT"); b.Property("CreatedOn") @@ -57,7 +57,7 @@ namespace LANCommander.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("UpdatedById") + b.Property("UpdatedById") .HasColumnType("TEXT"); b.Property("UpdatedOn") @@ -69,11 +69,15 @@ namespace LANCommander.Migrations b.HasKey("Id"); + b.HasIndex("CreatedById"); + b.HasIndex("GameId"); b.HasIndex("LastVersionId"); - b.ToTable("Archive", (string)null); + b.HasIndex("UpdatedById"); + + b.ToTable("Archive"); }); modelBuilder.Entity("LANCommander.Data.Models.Company", b => @@ -82,7 +86,7 @@ namespace LANCommander.Migrations .ValueGeneratedOnAdd() .HasColumnType("TEXT"); - b.Property("CreatedById") + b.Property("CreatedById") .HasColumnType("TEXT"); b.Property("CreatedOn") @@ -92,7 +96,7 @@ namespace LANCommander.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("UpdatedById") + b.Property("UpdatedById") .HasColumnType("TEXT"); b.Property("UpdatedOn") @@ -100,7 +104,11 @@ namespace LANCommander.Migrations b.HasKey("Id"); - b.ToTable("Companies", (string)null); + b.HasIndex("CreatedById"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Companies"); }); modelBuilder.Entity("LANCommander.Data.Models.Game", b => @@ -109,7 +117,7 @@ namespace LANCommander.Migrations .ValueGeneratedOnAdd() .HasColumnType("TEXT"); - b.Property("CreatedById") + b.Property("CreatedById") .HasColumnType("TEXT"); b.Property("CreatedOn") @@ -138,7 +146,7 @@ namespace LANCommander.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("UpdatedById") + b.Property("UpdatedById") .HasColumnType("TEXT"); b.Property("UpdatedOn") @@ -146,11 +154,15 @@ namespace LANCommander.Migrations b.HasKey("Id"); + b.HasIndex("CreatedById"); + b.HasIndex("DeveloperId"); b.HasIndex("PublisherId"); - b.ToTable("Games", (string)null); + b.HasIndex("UpdatedById"); + + b.ToTable("Games"); }); modelBuilder.Entity("LANCommander.Data.Models.Tag", b => @@ -159,7 +171,7 @@ namespace LANCommander.Migrations .ValueGeneratedOnAdd() .HasColumnType("TEXT"); - b.Property("CreatedById") + b.Property("CreatedById") .HasColumnType("TEXT"); b.Property("CreatedOn") @@ -169,7 +181,7 @@ namespace LANCommander.Migrations .IsRequired() .HasColumnType("TEXT"); - b.Property("UpdatedById") + b.Property("UpdatedById") .HasColumnType("TEXT"); b.Property("UpdatedOn") @@ -177,12 +189,17 @@ namespace LANCommander.Migrations b.HasKey("Id"); - b.ToTable("Tags", (string)null); + b.HasIndex("CreatedById"); + + b.HasIndex("UpdatedById"); + + b.ToTable("Tags"); }); modelBuilder.Entity("LANCommander.Data.Models.User", b => { - b.Property("Id") + b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("AccessFailedCount") @@ -244,9 +261,10 @@ namespace LANCommander.Migrations b.ToTable("AspNetUsers", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRole", b => { - b.Property("Id") + b.Property("Id") + .ValueGeneratedOnAdd() .HasColumnType("TEXT"); b.Property("ConcurrencyStamp") @@ -270,7 +288,7 @@ namespace LANCommander.Migrations b.ToTable("AspNetRoles", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -282,8 +300,7 @@ namespace LANCommander.Migrations b.Property("ClaimValue") .HasColumnType("TEXT"); - b.Property("RoleId") - .IsRequired() + b.Property("RoleId") .HasColumnType("TEXT"); b.HasKey("Id"); @@ -293,7 +310,7 @@ namespace LANCommander.Migrations b.ToTable("AspNetRoleClaims", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.Property("Id") .ValueGeneratedOnAdd() @@ -305,8 +322,7 @@ namespace LANCommander.Migrations b.Property("ClaimValue") .HasColumnType("TEXT"); - b.Property("UserId") - .IsRequired() + b.Property("UserId") .HasColumnType("TEXT"); b.HasKey("Id"); @@ -316,7 +332,7 @@ namespace LANCommander.Migrations b.ToTable("AspNetUserClaims", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.Property("LoginProvider") .HasMaxLength(128) @@ -329,8 +345,7 @@ namespace LANCommander.Migrations b.Property("ProviderDisplayName") .HasColumnType("TEXT"); - b.Property("UserId") - .IsRequired() + b.Property("UserId") .HasColumnType("TEXT"); b.HasKey("LoginProvider", "ProviderKey"); @@ -340,12 +355,12 @@ namespace LANCommander.Migrations b.ToTable("AspNetUserLogins", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.Property("UserId") + b.Property("UserId") .HasColumnType("TEXT"); - b.Property("RoleId") + b.Property("RoleId") .HasColumnType("TEXT"); b.HasKey("UserId", "RoleId"); @@ -355,9 +370,9 @@ namespace LANCommander.Migrations b.ToTable("AspNetUserRoles", (string)null); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { - b.Property("UserId") + b.Property("UserId") .HasColumnType("TEXT"); b.Property("LoginProvider") @@ -393,6 +408,10 @@ namespace LANCommander.Migrations modelBuilder.Entity("LANCommander.Data.Models.Archive", b => { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + b.HasOne("LANCommander.Data.Models.Game", "Game") .WithMany("Archives") .HasForeignKey("GameId"); @@ -401,13 +420,40 @@ namespace LANCommander.Migrations .WithMany() .HasForeignKey("LastVersionId"); + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + b.Navigation("Game"); b.Navigation("LastVersion"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("LANCommander.Data.Models.Company", b => + { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("UpdatedBy"); }); modelBuilder.Entity("LANCommander.Data.Models.Game", b => { + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + b.HasOne("LANCommander.Data.Models.Company", "Developer") .WithMany("DevelopedGames") .HasForeignKey("DeveloperId"); @@ -416,21 +462,44 @@ namespace LANCommander.Migrations .WithMany("PublishedGames") .HasForeignKey("PublisherId"); + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + b.Navigation("Developer"); b.Navigation("Publisher"); + + b.Navigation("UpdatedBy"); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + modelBuilder.Entity("LANCommander.Data.Models.Tag", b => { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + b.HasOne("LANCommander.Data.Models.User", "CreatedBy") + .WithMany() + .HasForeignKey("CreatedById"); + + b.HasOne("LANCommander.Data.Models.User", "UpdatedBy") + .WithMany() + .HasForeignKey("UpdatedById"); + + b.Navigation("CreatedBy"); + + b.Navigation("UpdatedBy"); + }); + + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityRoleClaim", b => + { + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserClaim", b => { b.HasOne("LANCommander.Data.Models.User", null) .WithMany() @@ -439,7 +508,7 @@ namespace LANCommander.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserLogin", b => { b.HasOne("LANCommander.Data.Models.User", null) .WithMany() @@ -448,9 +517,9 @@ namespace LANCommander.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserRole", b => { - b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) + b.HasOne("Microsoft.AspNetCore.Identity.IdentityRole", null) .WithMany() .HasForeignKey("RoleId") .OnDelete(DeleteBehavior.Cascade) @@ -463,7 +532,7 @@ namespace LANCommander.Migrations .IsRequired(); }); - modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => + modelBuilder.Entity("Microsoft.AspNetCore.Identity.IdentityUserToken", b => { b.HasOne("LANCommander.Data.Models.User", null) .WithMany() diff --git a/Program.cs b/Program.cs index e987133..649fa50 100644 --- a/Program.cs +++ b/Program.cs @@ -2,6 +2,7 @@ using LANCommander.Data; using LANCommander.Data.Models; using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; var builder = WebApplication.CreateBuilder(args); @@ -20,7 +21,7 @@ builder.Services.AddDefaultIdentity((IdentityOptions options) => { options.SignIn.RequireConfirmedAccount = true; options.Password.RequireNonAlphanumeric = false; options.SignIn.RequireConfirmedEmail = false; -}).AddEntityFrameworkStores(); +}).AddEntityFrameworkStores(); builder.Services.AddControllersWithViews(); diff --git a/Views/Companies/Create.cshtml b/Views/Companies/Create.cshtml index ef18cfe..a63e57c 100644 --- a/Views/Companies/Create.cshtml +++ b/Views/Companies/Create.cshtml @@ -22,21 +22,11 @@ -
- - - -
-
- - - -
diff --git a/Views/Companies/Delete.cshtml b/Views/Companies/Delete.cshtml index 094aaae..0528677 100644 --- a/Views/Companies/Delete.cshtml +++ b/Views/Companies/Delete.cshtml @@ -23,24 +23,12 @@
@Html.DisplayFor(model => model.CreatedOn)
-
- @Html.DisplayNameFor(model => model.CreatedById) -
-
- @Html.DisplayFor(model => model.CreatedById) -
@Html.DisplayNameFor(model => model.UpdatedOn)
@Html.DisplayFor(model => model.UpdatedOn)
-
- @Html.DisplayNameFor(model => model.UpdatedById) -
-
- @Html.DisplayFor(model => model.UpdatedById) -
diff --git a/Views/Companies/Details.cshtml b/Views/Companies/Details.cshtml index abb713c..ab17f90 100644 --- a/Views/Companies/Details.cshtml +++ b/Views/Companies/Details.cshtml @@ -22,24 +22,12 @@
@Html.DisplayFor(model => model.CreatedOn)
-
- @Html.DisplayNameFor(model => model.CreatedById) -
-
- @Html.DisplayFor(model => model.CreatedById) -
@Html.DisplayNameFor(model => model.UpdatedOn)
@Html.DisplayFor(model => model.UpdatedOn)
-
- @Html.DisplayNameFor(model => model.UpdatedById) -
-
- @Html.DisplayFor(model => model.UpdatedById) -
diff --git a/Views/Companies/Edit.cshtml b/Views/Companies/Edit.cshtml index 3f44bce..6d5f879 100644 --- a/Views/Companies/Edit.cshtml +++ b/Views/Companies/Edit.cshtml @@ -23,21 +23,11 @@
-
- - - -
-
- - - -
diff --git a/Views/Companies/Index.cshtml b/Views/Companies/Index.cshtml index d98c312..bdf83b8 100644 --- a/Views/Companies/Index.cshtml +++ b/Views/Companies/Index.cshtml @@ -18,15 +18,9 @@ @Html.DisplayNameFor(model => model.CreatedOn) - - @Html.DisplayNameFor(model => model.CreatedById) - @Html.DisplayNameFor(model => model.UpdatedOn) - - @Html.DisplayNameFor(model => model.UpdatedById) - @@ -39,15 +33,9 @@ @Html.DisplayFor(modelItem => item.CreatedOn) - - @Html.DisplayFor(modelItem => item.CreatedById) - @Html.DisplayFor(modelItem => item.UpdatedOn) - - @Html.DisplayFor(modelItem => item.UpdatedById) - Edit | Details | diff --git a/Views/Games/Delete.cshtml b/Views/Games/Delete.cshtml index 688afbb..790d342 100644 --- a/Views/Games/Delete.cshtml +++ b/Views/Games/Delete.cshtml @@ -41,24 +41,12 @@
@Html.DisplayFor(model => model.CreatedOn)
-
- @Html.DisplayNameFor(model => model.CreatedById) -
-
- @Html.DisplayFor(model => model.CreatedById) -
@Html.DisplayNameFor(model => model.UpdatedOn)
@Html.DisplayFor(model => model.UpdatedOn)
-
- @Html.DisplayNameFor(model => model.UpdatedById) -
-
- @Html.DisplayFor(model => model.UpdatedById) -
diff --git a/Views/Games/Details.cshtml b/Views/Games/Details.cshtml index 5ee13ea..387f1c2 100644 --- a/Views/Games/Details.cshtml +++ b/Views/Games/Details.cshtml @@ -41,10 +41,10 @@ @Html.DisplayFor(model => model.CreatedOn)
- @Html.DisplayNameFor(model => model.CreatedById) + @Html.DisplayNameFor(model => model.CreatedBy)
- @Html.DisplayFor(model => model.CreatedById) + @Html.DisplayFor(model => model.CreatedBy.UserName)
@Html.DisplayNameFor(model => model.UpdatedOn) @@ -53,10 +53,10 @@ @Html.DisplayFor(model => model.UpdatedOn)
- @Html.DisplayNameFor(model => model.UpdatedById) + @Html.DisplayNameFor(model => model.UpdatedBy)
- @Html.DisplayFor(model => model.UpdatedById) + @Html.DisplayFor(model => model.UpdatedBy.UserName)
diff --git a/Views/Games/Edit.cshtml b/Views/Games/Edit.cshtml index 0739e09..9458f92 100644 --- a/Views/Games/Edit.cshtml +++ b/Views/Games/Edit.cshtml @@ -33,26 +33,6 @@ -
- - - -
-
- - - -
-
- - - -
-
- - - -
diff --git a/Views/Games/Index.cshtml b/Views/Games/Index.cshtml index accce9d..3cd9f87 100644 --- a/Views/Games/Index.cshtml +++ b/Views/Games/Index.cshtml @@ -28,13 +28,13 @@ @Html.DisplayNameFor(model => model.CreatedOn) - @Html.DisplayNameFor(model => model.CreatedById) + @Html.DisplayNameFor(model => model.CreatedBy) @Html.DisplayNameFor(model => model.UpdatedOn) - @Html.DisplayNameFor(model => model.UpdatedById) + @Html.DisplayNameFor(model => model.UpdatedBy) @@ -58,13 +58,13 @@ @Html.DisplayFor(modelItem => item.CreatedOn) - @Html.DisplayFor(modelItem => item.CreatedById) + @Html.DisplayFor(modelItem => item.CreatedBy.UserName) @Html.DisplayFor(modelItem => item.UpdatedOn) - @Html.DisplayFor(modelItem => item.UpdatedById) + @Html.DisplayFor(modelItem => item.UpdatedBy.UserName) Edit | diff --git a/Views/Shared/_Layout.cshtml b/Views/Shared/_Layout.cshtml index 4e95bda..911a4cb 100644 --- a/Views/Shared/_Layout.cshtml +++ b/Views/Shared/_Layout.cshtml @@ -22,6 +22,9 @@ + diff --git a/Views/Tags/Create.cshtml b/Views/Tags/Create.cshtml index 839ccad..e8d8412 100644 --- a/Views/Tags/Create.cshtml +++ b/Views/Tags/Create.cshtml @@ -22,21 +22,11 @@ -
- - - -
-
- - - -
diff --git a/Views/Tags/Delete.cshtml b/Views/Tags/Delete.cshtml index f74e1ed..a9581d1 100644 --- a/Views/Tags/Delete.cshtml +++ b/Views/Tags/Delete.cshtml @@ -23,24 +23,12 @@
@Html.DisplayFor(model => model.CreatedOn)
-
- @Html.DisplayNameFor(model => model.CreatedById) -
-
- @Html.DisplayFor(model => model.CreatedById) -
@Html.DisplayNameFor(model => model.UpdatedOn)
@Html.DisplayFor(model => model.UpdatedOn)
-
- @Html.DisplayNameFor(model => model.UpdatedById) -
-
- @Html.DisplayFor(model => model.UpdatedById) -
diff --git a/Views/Tags/Details.cshtml b/Views/Tags/Details.cshtml index caf105c..0315ae3 100644 --- a/Views/Tags/Details.cshtml +++ b/Views/Tags/Details.cshtml @@ -22,24 +22,12 @@
@Html.DisplayFor(model => model.CreatedOn)
-
- @Html.DisplayNameFor(model => model.CreatedById) -
-
- @Html.DisplayFor(model => model.CreatedById) -
@Html.DisplayNameFor(model => model.UpdatedOn)
@Html.DisplayFor(model => model.UpdatedOn)
-
- @Html.DisplayNameFor(model => model.UpdatedById) -
-
- @Html.DisplayFor(model => model.UpdatedById) -
diff --git a/Views/Tags/Edit.cshtml b/Views/Tags/Edit.cshtml index d60d67c..41b8833 100644 --- a/Views/Tags/Edit.cshtml +++ b/Views/Tags/Edit.cshtml @@ -23,21 +23,11 @@
-
- - - -
-
- - - -
diff --git a/Views/Tags/Index.cshtml b/Views/Tags/Index.cshtml index 7ed51b2..c967417 100644 --- a/Views/Tags/Index.cshtml +++ b/Views/Tags/Index.cshtml @@ -18,15 +18,9 @@ @Html.DisplayNameFor(model => model.CreatedOn) - - @Html.DisplayNameFor(model => model.CreatedById) - @Html.DisplayNameFor(model => model.UpdatedOn) - - @Html.DisplayNameFor(model => model.UpdatedById) - @@ -39,15 +33,9 @@ @Html.DisplayFor(modelItem => item.CreatedOn) - - @Html.DisplayFor(modelItem => item.CreatedById) - @Html.DisplayFor(modelItem => item.UpdatedOn) - - @Html.DisplayFor(modelItem => item.UpdatedById) - Edit | Details |