diff --git a/DrinkRateAPI/Contexts/ApplicationDbContext.cs b/DrinkRateAPI/Contexts/ApplicationDbContext.cs index 5e30588..17335b0 100644 --- a/DrinkRateAPI/Contexts/ApplicationDbContext.cs +++ b/DrinkRateAPI/Contexts/ApplicationDbContext.cs @@ -15,9 +15,11 @@ public class ApplicationDbContext : DbContext public DbSet ProductTable { get; set; } public DbSet ProductTableView { get; set; } - public DbSet Users { get; set; } - public DbSet UserCompanyTableStats { get; set; } - public DbSet UserProductTableStats { get; set; } + public DbSet UserProfiles { get; set; } + public DbSet UserProfileCompanyTableStats { get; set; } + public DbSet UserProfileProductTableStats { get; set; } + + public DbSet ApplicationUsers { get; set; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { @@ -58,10 +60,10 @@ public class ApplicationDbContext : DbContext // Company Rating modelBuilder.Entity(entity => { - entity.HasKey(cr => new { cr.UserId, cr.CompanyId }); + entity.HasKey(cr => new { cr.UserProfileId, cr.CompanyId }); - entity.HasOne(cr => cr.User) - .WithMany(u => u.CompanyRatings); + entity.HasOne(cr => cr.UserProfile) + .WithMany(up => up.CompanyRatings); entity.HasOne(cr => cr.Company) .WithMany(c => c.CompanyRatings); @@ -88,8 +90,8 @@ public class ApplicationDbContext : DbContext entity.HasMany(ctv => ctv.CompanyTables) .WithMany(); - entity.HasMany(ctv => ctv.Users) - .WithMany(u => u.CompanyTableViews); + entity.HasMany(ctv => ctv.UserProfiles) + .WithMany(up => up.CompanyTableViews); }); // Product @@ -122,10 +124,10 @@ public class ApplicationDbContext : DbContext // Product Rating modelBuilder.Entity(entity => { - entity.HasKey(pr => new { pr.UserId, pr.ProductId }); + entity.HasKey(pr => new { pr.UserProfileId, pr.ProductId }); - entity.HasOne(pr => pr.User) - .WithMany(u => u.ProductRatings); + entity.HasOne(pr => pr.UserProfile) + .WithMany(up => up.ProductRatings); entity.HasOne(pr => pr.Product) .WithMany(p => p.ProductRatings); @@ -152,62 +154,66 @@ public class ApplicationDbContext : DbContext entity.HasMany(ptv => ptv.ProductTables) .WithMany(); - entity.HasMany(ptv => ptv.Users) + entity.HasMany(ptv => ptv.UserProfiles) .WithMany(u => u.ProductTableViews); }); // User - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { - entity.HasKey(u => u.Id); + entity.HasKey(up => up.Id); - entity.HasMany(u => u.CompanyTableViews) - .WithMany(ctv => ctv.Users); + entity.HasMany(up => up.CompanyTableViews) + .WithMany(ctv => ctv.UserProfiles); - entity.HasMany(u => u.ProductTableViews) - .WithMany(ptv => ptv.Users); + entity.HasMany(up => up.ProductTableViews) + .WithMany(ptv => ptv.UserProfiles); - entity.HasMany(u => u.CompanyRatings) - .WithOne(cr => cr.User) - .HasForeignKey(cr => cr.UserId); + entity.HasMany(up => up.CompanyRatings) + .WithOne(cr => cr.UserProfile) + .HasForeignKey(cr => cr.UserProfileId); - entity.HasMany(u => u.ProductRatings) - .WithOne(pr => pr.User) - .HasForeignKey(pr => pr.UserId); + entity.HasMany(up => up.ProductRatings) + .WithOne(pr => pr.UserProfile) + .HasForeignKey(pr => pr.UserProfileId); - entity.HasMany(u => u.UserCompanyTableStats) - .WithOne(ucts => ucts.User) - .HasForeignKey(ucts => ucts.UserId); + entity.HasMany(up => up.UserProfileCompanyTableStats) + .WithOne(upcts => upcts.UserProfile) + .HasForeignKey(upcts => upcts.UserId); - entity.HasMany(u => u.UserProductTableStats) - .WithOne(upts => upts.User) - .HasForeignKey(upts => upts.UserId); + entity.HasMany(up => up.UserProfileProductTableStats) + .WithOne(uppts => uppts.UserProfile) + .HasForeignKey(uppts => uppts.UserId); - entity.HasIndex(u => u.UserName) + entity.HasIndex(up => up.UserName) .IsUnique(); + + entity.HasOne(up => up.ApplicationUser) + .WithOne(au => au.UserProfile) + .HasForeignKey(up => up.ApplicationUserId); }); // User Company Table Stat - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { - entity.HasKey(ucts => new { ucts.UserId, ucts.CompanyTableId }); + entity.HasKey(upcts => new { upcts.UserId, upcts.CompanyTableId }); - entity.HasOne(ucts => ucts.User) - .WithMany(u => u.UserCompanyTableStats); + entity.HasOne(upcts => upcts.UserProfile) + .WithMany(up => up.UserProfileCompanyTableStats); - entity.HasOne(ucts => ucts.CompanyTable) + entity.HasOne(upcts => upcts.CompanyTable) .WithMany(); }); // User Product Table Stat - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { - entity.HasKey(upts => new { upts.UserId, upts.ProductTableId }); + entity.HasKey(uppts => new { uppts.UserId, uppts.ProductTableId }); - entity.HasOne(upts => upts.User) - .WithMany(u => u.UserProductTableStats); + entity.HasOne(uppts => uppts.UserProfile) + .WithMany(up => up.UserProfileProductTableStats); - entity.HasOne(upts => upts.ProductTable) + entity.HasOne(uppts => uppts.ProductTable) .WithMany(); }); } diff --git a/DrinkRateAPI/Contexts/IdentityDbContext.cs b/DrinkRateAPI/Contexts/IdentityDbContext.cs index 57a3a45..2c9aaef 100644 --- a/DrinkRateAPI/Contexts/IdentityDbContext.cs +++ b/DrinkRateAPI/Contexts/IdentityDbContext.cs @@ -1,10 +1,10 @@ +using DrinkRateAPI.DbEntities; using Microsoft.AspNetCore.Identity.EntityFrameworkCore; -using Microsoft.AspNetCore.Identity; using Microsoft.EntityFrameworkCore; namespace DrinkRateAPI.Contexts; -public class IdentityDbContext : IdentityDbContext +public class IdentityDbContext : IdentityDbContext { public IdentityDbContext(DbContextOptions options) : base(options) diff --git a/DrinkRateAPI/DbEntities/DbApplicationUser.cs b/DrinkRateAPI/DbEntities/DbApplicationUser.cs new file mode 100644 index 0000000..eef7d73 --- /dev/null +++ b/DrinkRateAPI/DbEntities/DbApplicationUser.cs @@ -0,0 +1,8 @@ +using Microsoft.AspNetCore.Identity; + +namespace DrinkRateAPI.DbEntities; + +public class DbApplicationUser : IdentityUser +{ + public virtual DbUserProfile UserProfile { get; set; } +} \ No newline at end of file diff --git a/DrinkRateAPI/DbEntities/DbCompanyRating.cs b/DrinkRateAPI/DbEntities/DbCompanyRating.cs index 2d18441..2d51cb8 100644 --- a/DrinkRateAPI/DbEntities/DbCompanyRating.cs +++ b/DrinkRateAPI/DbEntities/DbCompanyRating.cs @@ -2,8 +2,8 @@ namespace DrinkRateAPI.DbEntities; public class DbCompanyRating { - public Guid UserId { get; set; } - public DbUser User { get; set; } + public Guid UserProfileId { get; set; } + public DbUserProfile UserProfile { get; set; } public Guid CompanyId { get; set; } public DbCompany Company { get; set; } diff --git a/DrinkRateAPI/DbEntities/DbCompanyTableView.cs b/DrinkRateAPI/DbEntities/DbCompanyTableView.cs index f544e31..ad85b1c 100644 --- a/DrinkRateAPI/DbEntities/DbCompanyTableView.cs +++ b/DrinkRateAPI/DbEntities/DbCompanyTableView.cs @@ -6,7 +6,7 @@ public class DbCompanyTableView public ICollection CompanyTables { get; set; } - public ICollection Users { get; set; } + public ICollection UserProfiles { get; set; } // to do: permission types } \ No newline at end of file diff --git a/DrinkRateAPI/DbEntities/DbProductRating.cs b/DrinkRateAPI/DbEntities/DbProductRating.cs index 85f51e8..5b0162a 100644 --- a/DrinkRateAPI/DbEntities/DbProductRating.cs +++ b/DrinkRateAPI/DbEntities/DbProductRating.cs @@ -2,8 +2,8 @@ namespace DrinkRateAPI.DbEntities; public class DbProductRating { - public Guid UserId { get; set; } - public DbUser User { get; set; } + public Guid UserProfileId { get; set; } + public DbUserProfile UserProfile { get; set; } public Guid ProductId { get; set; } public DbProduct Product { get; set; } diff --git a/DrinkRateAPI/DbEntities/DbProductTableView.cs b/DrinkRateAPI/DbEntities/DbProductTableView.cs index 594ec1c..5a0bcf1 100644 --- a/DrinkRateAPI/DbEntities/DbProductTableView.cs +++ b/DrinkRateAPI/DbEntities/DbProductTableView.cs @@ -6,7 +6,7 @@ public class DbProductTableView public ICollection ProductTables { get; set; } - public ICollection Users { get; set; } + public ICollection UserProfiles { get; set; } // to do: permission types } \ No newline at end of file diff --git a/DrinkRateAPI/DbEntities/DbUser.cs b/DrinkRateAPI/DbEntities/DbUserProfile.cs similarity index 55% rename from DrinkRateAPI/DbEntities/DbUser.cs rename to DrinkRateAPI/DbEntities/DbUserProfile.cs index 2204f9d..94fd746 100644 --- a/DrinkRateAPI/DbEntities/DbUser.cs +++ b/DrinkRateAPI/DbEntities/DbUserProfile.cs @@ -1,6 +1,8 @@ +using Microsoft.AspNetCore.Identity; + namespace DrinkRateAPI.DbEntities; -public class DbUser +public class DbUserProfile { public Guid Id { get; set; } @@ -10,12 +12,16 @@ public class DbUser public ICollection CompanyRatings { get; set; } public ICollection ProductRatings { get; set; } - public ICollection UserCompanyTableStats { get; set; } - public ICollection UserProductTableStats { get; set; } + public ICollection UserProfileCompanyTableStats { get; set; } + public ICollection UserProfileProductTableStats { get; set; } public string UserName { get; set; } public bool IsAdmin { get; set; } public bool IsDeleted { get; set; } + + public string ApplicationUserId { get; set; } + + public virtual DbApplicationUser ApplicationUser { get; set; } } \ No newline at end of file diff --git a/DrinkRateAPI/DbEntities/DbUserCompanyTableStat.cs b/DrinkRateAPI/DbEntities/DbUserProfileCompanyTableStat.cs similarity index 76% rename from DrinkRateAPI/DbEntities/DbUserCompanyTableStat.cs rename to DrinkRateAPI/DbEntities/DbUserProfileCompanyTableStat.cs index fb8f337..4466d92 100644 --- a/DrinkRateAPI/DbEntities/DbUserCompanyTableStat.cs +++ b/DrinkRateAPI/DbEntities/DbUserProfileCompanyTableStat.cs @@ -1,9 +1,9 @@ namespace DrinkRateAPI.DbEntities; -public class DbUserCompanyTableStat +public class DbUserProfileCompanyTableStat { public Guid UserId { get; set; } - public DbUser User { get; set; } + public DbUserProfile UserProfile { get; set; } public Guid CompanyTableId { get; set; } public DbCompanyTable CompanyTable { get; set; } diff --git a/DrinkRateAPI/DbEntities/DbUserProductTableStat.cs b/DrinkRateAPI/DbEntities/DbUserProfileProductTableStat.cs similarity index 76% rename from DrinkRateAPI/DbEntities/DbUserProductTableStat.cs rename to DrinkRateAPI/DbEntities/DbUserProfileProductTableStat.cs index 961c29e..d222070 100644 --- a/DrinkRateAPI/DbEntities/DbUserProductTableStat.cs +++ b/DrinkRateAPI/DbEntities/DbUserProfileProductTableStat.cs @@ -1,9 +1,9 @@ namespace DrinkRateAPI.DbEntities; -public class DbUserProductTableStat +public class DbUserProfileProductTableStat { public Guid UserId { get; set; } - public DbUser User { get; set; } + public DbUserProfile UserProfile { get; set; } public Guid ProductTableId { get; set; } public DbProductTable ProductTable { get; set; } diff --git a/DrinkRateAPI/DrinkRateAPI.csproj b/DrinkRateAPI/DrinkRateAPI.csproj index 997e5d9..dacaac5 100644 --- a/DrinkRateAPI/DrinkRateAPI.csproj +++ b/DrinkRateAPI/DrinkRateAPI.csproj @@ -19,4 +19,8 @@ + + + + \ No newline at end of file diff --git a/DrinkRateAPI/Migrations/20250809085523_250809_ApplicationInit.Designer.cs b/DrinkRateAPI/Migrations/20250809085523_250809_ApplicationInit.Designer.cs deleted file mode 100644 index cf1b9a9..0000000 --- a/DrinkRateAPI/Migrations/20250809085523_250809_ApplicationInit.Designer.cs +++ /dev/null @@ -1,29 +0,0 @@ -// -using DrinkRateAPI.Contexts; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; - -#nullable disable - -namespace DrinkRateAPI.Migrations -{ - [DbContext(typeof(ApplicationDbContext))] - [Migration("20250809085523_250809_ApplicationInit")] - partial class _250809_ApplicationInit - { - /// - protected override void BuildTargetModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "9.0.8") - .HasAnnotation("Relational:MaxIdentifierLength", 128); - - SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); -#pragma warning restore 612, 618 - } - } -} diff --git a/DrinkRateAPI/Migrations/20250809085523_250809_ApplicationInit.cs b/DrinkRateAPI/Migrations/20250809085523_250809_ApplicationInit.cs deleted file mode 100644 index bde9c50..0000000 --- a/DrinkRateAPI/Migrations/20250809085523_250809_ApplicationInit.cs +++ /dev/null @@ -1,22 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -#nullable disable - -namespace DrinkRateAPI.Migrations -{ - /// - public partial class _250809_ApplicationInit : Migration - { - /// - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - /// - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/DrinkRateAPI/Migrations/20250809121142_BaseDbModel.Designer.cs b/DrinkRateAPI/Migrations/20250809134029_Init.Designer.cs similarity index 74% rename from DrinkRateAPI/Migrations/20250809121142_BaseDbModel.Designer.cs rename to DrinkRateAPI/Migrations/20250809134029_Init.Designer.cs index 8f0b838..9606caf 100644 --- a/DrinkRateAPI/Migrations/20250809121142_BaseDbModel.Designer.cs +++ b/DrinkRateAPI/Migrations/20250809134029_Init.Designer.cs @@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace DrinkRateAPI.Migrations { [DbContext(typeof(ApplicationDbContext))] - [Migration("20250809121142_BaseDbModel")] - partial class BaseDbModel + [Migration("20250809134029_Init")] + partial class Init { /// protected override void BuildTargetModel(ModelBuilder modelBuilder) @@ -40,19 +40,19 @@ namespace DrinkRateAPI.Migrations b.ToTable("DbCompanyTableDbCompanyTableView"); }); - modelBuilder.Entity("DbCompanyTableViewDbUser", b => + modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b => { b.Property("CompanyTableViewsId") .HasColumnType("uuid"); - b.Property("UsersId") + b.Property("UserProfilesId") .HasColumnType("uuid"); - b.HasKey("CompanyTableViewsId", "UsersId"); + b.HasKey("CompanyTableViewsId", "UserProfilesId"); - b.HasIndex("UsersId"); + b.HasIndex("UserProfilesId"); - b.ToTable("DbCompanyTableViewDbUser"); + b.ToTable("DbCompanyTableViewDbUserProfile"); }); modelBuilder.Entity("DbProductTableDbProductTableView", b => @@ -70,19 +70,71 @@ namespace DrinkRateAPI.Migrations b.ToTable("DbProductTableDbProductTableView"); }); - modelBuilder.Entity("DbProductTableViewDbUser", b => + modelBuilder.Entity("DbProductTableViewDbUserProfile", b => { b.Property("ProductTableViewsId") .HasColumnType("uuid"); - b.Property("UsersId") + b.Property("UserProfilesId") .HasColumnType("uuid"); - b.HasKey("ProductTableViewsId", "UsersId"); + b.HasKey("ProductTableViewsId", "UserProfilesId"); - b.HasIndex("UsersId"); + b.HasIndex("UserProfilesId"); - b.ToTable("DbProductTableViewDbUser"); + b.ToTable("DbProductTableViewDbUserProfile"); + }); + + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .HasColumnType("text"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasColumnType("text"); + + b.Property("NormalizedUserName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ApplicationUsers"); }); modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b => @@ -117,7 +169,7 @@ namespace DrinkRateAPI.Migrations modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b => { - b.Property("UserId") + b.Property("UserProfileId") .HasColumnType("uuid"); b.Property("CompanyId") @@ -129,7 +181,7 @@ namespace DrinkRateAPI.Migrations b.Property("Rating") .HasColumnType("smallint"); - b.HasKey("UserId", "CompanyId"); + b.HasKey("UserProfileId", "CompanyId"); b.HasIndex("CompanyId"); @@ -202,7 +254,7 @@ namespace DrinkRateAPI.Migrations modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b => { - b.Property("UserId") + b.Property("UserProfileId") .HasColumnType("uuid"); b.Property("ProductId") @@ -214,7 +266,7 @@ namespace DrinkRateAPI.Migrations b.Property("Rating") .HasColumnType("smallint"); - b.HasKey("UserId", "ProductId"); + b.HasKey("UserProfileId", "ProductId"); b.HasIndex("ProductId"); @@ -250,12 +302,16 @@ namespace DrinkRateAPI.Migrations b.ToTable("ProductTableView"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUser", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("ApplicationUserId") + .IsRequired() + .HasColumnType("text"); + b.Property("IsAdmin") .HasColumnType("boolean"); @@ -268,13 +324,16 @@ namespace DrinkRateAPI.Migrations b.HasKey("Id"); + b.HasIndex("ApplicationUserId") + .IsUnique(); + b.HasIndex("UserName") .IsUnique(); - b.ToTable("Users"); + b.ToTable("UserProfiles"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserCompanyTableStat", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b => { b.Property("UserId") .HasColumnType("uuid"); @@ -295,10 +354,10 @@ namespace DrinkRateAPI.Migrations b.HasIndex("CompanyTableId"); - b.ToTable("UserCompanyTableStats"); + b.ToTable("UserProfileCompanyTableStats"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProductTableStat", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b => { b.Property("UserId") .HasColumnType("uuid"); @@ -319,7 +378,7 @@ namespace DrinkRateAPI.Migrations b.HasIndex("ProductTableId"); - b.ToTable("UserProductTableStats"); + b.ToTable("UserProfileProductTableStats"); }); modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b => @@ -337,7 +396,7 @@ namespace DrinkRateAPI.Migrations .IsRequired(); }); - modelBuilder.Entity("DbCompanyTableViewDbUser", b => + modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b => { b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null) .WithMany() @@ -345,9 +404,9 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", null) + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null) .WithMany() - .HasForeignKey("UsersId") + .HasForeignKey("UserProfilesId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); @@ -367,7 +426,7 @@ namespace DrinkRateAPI.Migrations .IsRequired(); }); - modelBuilder.Entity("DbProductTableViewDbUser", b => + modelBuilder.Entity("DbProductTableViewDbUserProfile", b => { b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null) .WithMany() @@ -375,9 +434,9 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", null) + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null) .WithMany() - .HasForeignKey("UsersId") + .HasForeignKey("UserProfilesId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); @@ -401,15 +460,15 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile") .WithMany("CompanyRatings") - .HasForeignKey("UserId") + .HasForeignKey("UserProfileId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Company"); - b.Navigation("User"); + b.Navigation("UserProfile"); }); modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b => @@ -439,18 +498,29 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile") .WithMany("ProductRatings") - .HasForeignKey("UserId") + .HasForeignKey("UserProfileId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Product"); - b.Navigation("User"); + b.Navigation("UserProfile"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserCompanyTableStat", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b => + { + b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", "ApplicationUser") + .WithOne("UserProfile") + .HasForeignKey("DrinkRateAPI.DbEntities.DbUserProfile", "ApplicationUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicationUser"); + }); + + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b => { b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable") .WithMany() @@ -458,18 +528,18 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") - .WithMany("UserCompanyTableStats") + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile") + .WithMany("UserProfileCompanyTableStats") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("CompanyTable"); - b.Navigation("User"); + b.Navigation("UserProfile"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProductTableStat", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b => { b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable") .WithMany() @@ -477,15 +547,21 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") - .WithMany("UserProductTableStats") + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile") + .WithMany("UserProfileProductTableStats") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("ProductTable"); - b.Navigation("User"); + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b => + { + b.Navigation("UserProfile") + .IsRequired(); }); modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b => @@ -510,15 +586,15 @@ namespace DrinkRateAPI.Migrations b.Navigation("Products"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUser", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b => { b.Navigation("CompanyRatings"); b.Navigation("ProductRatings"); - b.Navigation("UserCompanyTableStats"); + b.Navigation("UserProfileCompanyTableStats"); - b.Navigation("UserProductTableStats"); + b.Navigation("UserProfileProductTableStats"); }); #pragma warning restore 612, 618 } diff --git a/DrinkRateAPI/Migrations/20250809121142_BaseDbModel.cs b/DrinkRateAPI/Migrations/20250809134029_Init.cs similarity index 73% rename from DrinkRateAPI/Migrations/20250809121142_BaseDbModel.cs rename to DrinkRateAPI/Migrations/20250809134029_Init.cs index 86ea95a..52db777 100644 --- a/DrinkRateAPI/Migrations/20250809121142_BaseDbModel.cs +++ b/DrinkRateAPI/Migrations/20250809134029_Init.cs @@ -6,11 +6,36 @@ using Microsoft.EntityFrameworkCore.Migrations; namespace DrinkRateAPI.Migrations { /// - public partial class BaseDbModel : Migration + public partial class Init : Migration { /// protected override void Up(MigrationBuilder migrationBuilder) { + migrationBuilder.CreateTable( + name: "ApplicationUsers", + columns: table => new + { + Id = table.Column(type: "text", nullable: false), + UserName = table.Column(type: "text", nullable: true), + NormalizedUserName = table.Column(type: "text", nullable: true), + Email = table.Column(type: "text", nullable: true), + NormalizedEmail = table.Column(type: "text", nullable: true), + EmailConfirmed = table.Column(type: "boolean", nullable: false), + PasswordHash = table.Column(type: "text", nullable: true), + SecurityStamp = table.Column(type: "text", nullable: true), + ConcurrencyStamp = table.Column(type: "text", nullable: true), + PhoneNumber = table.Column(type: "text", nullable: true), + PhoneNumberConfirmed = table.Column(type: "boolean", nullable: false), + TwoFactorEnabled = table.Column(type: "boolean", nullable: false), + LockoutEnd = table.Column(type: "timestamp with time zone", nullable: true), + LockoutEnabled = table.Column(type: "boolean", nullable: false), + AccessFailedCount = table.Column(type: "integer", nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_ApplicationUsers", x => x.Id); + }); + migrationBuilder.CreateTable( name: "CompanyTables", columns: table => new @@ -58,17 +83,24 @@ namespace DrinkRateAPI.Migrations }); migrationBuilder.CreateTable( - name: "Users", + name: "UserProfiles", columns: table => new { Id = table.Column(type: "uuid", nullable: false), UserName = table.Column(type: "text", nullable: false), IsAdmin = table.Column(type: "boolean", nullable: false), - IsDeleted = table.Column(type: "boolean", nullable: false) + IsDeleted = table.Column(type: "boolean", nullable: false), + ApplicationUserId = table.Column(type: "text", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_Users", x => x.Id); + table.PrimaryKey("PK_UserProfiles", x => x.Id); + table.ForeignKey( + name: "FK_UserProfiles_ApplicationUsers_ApplicationUserId", + column: x => x.ApplicationUserId, + principalTable: "ApplicationUsers", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( @@ -141,55 +173,55 @@ namespace DrinkRateAPI.Migrations }); migrationBuilder.CreateTable( - name: "DbCompanyTableViewDbUser", + name: "DbCompanyTableViewDbUserProfile", columns: table => new { CompanyTableViewsId = table.Column(type: "uuid", nullable: false), - UsersId = table.Column(type: "uuid", nullable: false) + UserProfilesId = table.Column(type: "uuid", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_DbCompanyTableViewDbUser", x => new { x.CompanyTableViewsId, x.UsersId }); + table.PrimaryKey("PK_DbCompanyTableViewDbUserProfile", x => new { x.CompanyTableViewsId, x.UserProfilesId }); table.ForeignKey( - name: "FK_DbCompanyTableViewDbUser_CompanyTableViews_CompanyTableView~", + name: "FK_DbCompanyTableViewDbUserProfile_CompanyTableViews_CompanyTa~", column: x => x.CompanyTableViewsId, principalTable: "CompanyTableViews", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_DbCompanyTableViewDbUser_Users_UsersId", - column: x => x.UsersId, - principalTable: "Users", + name: "FK_DbCompanyTableViewDbUserProfile_UserProfiles_UserProfilesId", + column: x => x.UserProfilesId, + principalTable: "UserProfiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( - name: "DbProductTableViewDbUser", + name: "DbProductTableViewDbUserProfile", columns: table => new { ProductTableViewsId = table.Column(type: "uuid", nullable: false), - UsersId = table.Column(type: "uuid", nullable: false) + UserProfilesId = table.Column(type: "uuid", nullable: false) }, constraints: table => { - table.PrimaryKey("PK_DbProductTableViewDbUser", x => new { x.ProductTableViewsId, x.UsersId }); + table.PrimaryKey("PK_DbProductTableViewDbUserProfile", x => new { x.ProductTableViewsId, x.UserProfilesId }); table.ForeignKey( - name: "FK_DbProductTableViewDbUser_ProductTableView_ProductTableViews~", + name: "FK_DbProductTableViewDbUserProfile_ProductTableView_ProductTab~", column: x => x.ProductTableViewsId, principalTable: "ProductTableView", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_DbProductTableViewDbUser_Users_UsersId", - column: x => x.UsersId, - principalTable: "Users", + name: "FK_DbProductTableViewDbUserProfile_UserProfiles_UserProfilesId", + column: x => x.UserProfilesId, + principalTable: "UserProfiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( - name: "UserCompanyTableStats", + name: "UserProfileCompanyTableStats", columns: table => new { UserId = table.Column(type: "uuid", nullable: false), @@ -200,23 +232,23 @@ namespace DrinkRateAPI.Migrations }, constraints: table => { - table.PrimaryKey("PK_UserCompanyTableStats", x => new { x.UserId, x.CompanyTableId }); + table.PrimaryKey("PK_UserProfileCompanyTableStats", x => new { x.UserId, x.CompanyTableId }); table.ForeignKey( - name: "FK_UserCompanyTableStats_CompanyTables_CompanyTableId", + name: "FK_UserProfileCompanyTableStats_CompanyTables_CompanyTableId", column: x => x.CompanyTableId, principalTable: "CompanyTables", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_UserCompanyTableStats_Users_UserId", + name: "FK_UserProfileCompanyTableStats_UserProfiles_UserId", column: x => x.UserId, - principalTable: "Users", + principalTable: "UserProfiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); migrationBuilder.CreateTable( - name: "UserProductTableStats", + name: "UserProfileProductTableStats", columns: table => new { UserId = table.Column(type: "uuid", nullable: false), @@ -227,17 +259,17 @@ namespace DrinkRateAPI.Migrations }, constraints: table => { - table.PrimaryKey("PK_UserProductTableStats", x => new { x.UserId, x.ProductTableId }); + table.PrimaryKey("PK_UserProfileProductTableStats", x => new { x.UserId, x.ProductTableId }); table.ForeignKey( - name: "FK_UserProductTableStats_ProductTable_ProductTableId", + name: "FK_UserProfileProductTableStats_ProductTable_ProductTableId", column: x => x.ProductTableId, principalTable: "ProductTable", principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_UserProductTableStats_Users_UserId", + name: "FK_UserProfileProductTableStats_UserProfiles_UserId", column: x => x.UserId, - principalTable: "Users", + principalTable: "UserProfiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -246,14 +278,14 @@ namespace DrinkRateAPI.Migrations name: "CompanyRatings", columns: table => new { - UserId = table.Column(type: "uuid", nullable: false), + UserProfileId = table.Column(type: "uuid", nullable: false), CompanyId = table.Column(type: "uuid", nullable: false), Rating = table.Column(type: "smallint", nullable: false), Comment = table.Column(type: "text", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_CompanyRatings", x => new { x.UserId, x.CompanyId }); + table.PrimaryKey("PK_CompanyRatings", x => new { x.UserProfileId, x.CompanyId }); table.ForeignKey( name: "FK_CompanyRatings_Companies_CompanyId", column: x => x.CompanyId, @@ -261,9 +293,9 @@ namespace DrinkRateAPI.Migrations principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_CompanyRatings_Users_UserId", - column: x => x.UserId, - principalTable: "Users", + name: "FK_CompanyRatings_UserProfiles_UserProfileId", + column: x => x.UserProfileId, + principalTable: "UserProfiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -300,14 +332,14 @@ namespace DrinkRateAPI.Migrations name: "ProductRating", columns: table => new { - UserId = table.Column(type: "uuid", nullable: false), + UserProfileId = table.Column(type: "uuid", nullable: false), ProductId = table.Column(type: "uuid", nullable: false), Rating = table.Column(type: "smallint", nullable: false), Comment = table.Column(type: "text", nullable: true) }, constraints: table => { - table.PrimaryKey("PK_ProductRating", x => new { x.UserId, x.ProductId }); + table.PrimaryKey("PK_ProductRating", x => new { x.UserProfileId, x.ProductId }); table.ForeignKey( name: "FK_ProductRating_Product_ProductId", column: x => x.ProductId, @@ -315,9 +347,9 @@ namespace DrinkRateAPI.Migrations principalColumn: "Id", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_ProductRating_Users_UserId", - column: x => x.UserId, - principalTable: "Users", + name: "FK_ProductRating_UserProfiles_UserProfileId", + column: x => x.UserProfileId, + principalTable: "UserProfiles", principalColumn: "Id", onDelete: ReferentialAction.Cascade); }); @@ -350,9 +382,9 @@ namespace DrinkRateAPI.Migrations column: "DbCompanyTableViewId"); migrationBuilder.CreateIndex( - name: "IX_DbCompanyTableViewDbUser_UsersId", - table: "DbCompanyTableViewDbUser", - column: "UsersId"); + name: "IX_DbCompanyTableViewDbUserProfile_UserProfilesId", + table: "DbCompanyTableViewDbUserProfile", + column: "UserProfilesId"); migrationBuilder.CreateIndex( name: "IX_DbProductTableDbProductTableView_ProductTablesId", @@ -360,9 +392,9 @@ namespace DrinkRateAPI.Migrations column: "ProductTablesId"); migrationBuilder.CreateIndex( - name: "IX_DbProductTableViewDbUser_UsersId", - table: "DbProductTableViewDbUser", - column: "UsersId"); + name: "IX_DbProductTableViewDbUserProfile_UserProfilesId", + table: "DbProductTableViewDbUserProfile", + column: "UserProfilesId"); migrationBuilder.CreateIndex( name: "IX_Product_CompanyId", @@ -392,18 +424,24 @@ namespace DrinkRateAPI.Migrations unique: true); migrationBuilder.CreateIndex( - name: "IX_UserCompanyTableStats_CompanyTableId", - table: "UserCompanyTableStats", + name: "IX_UserProfileCompanyTableStats_CompanyTableId", + table: "UserProfileCompanyTableStats", column: "CompanyTableId"); migrationBuilder.CreateIndex( - name: "IX_UserProductTableStats_ProductTableId", - table: "UserProductTableStats", + name: "IX_UserProfileProductTableStats_ProductTableId", + table: "UserProfileProductTableStats", column: "ProductTableId"); migrationBuilder.CreateIndex( - name: "IX_Users_UserName", - table: "Users", + name: "IX_UserProfiles_ApplicationUserId", + table: "UserProfiles", + column: "ApplicationUserId", + unique: true); + + migrationBuilder.CreateIndex( + name: "IX_UserProfiles_UserName", + table: "UserProfiles", column: "UserName", unique: true); } @@ -418,22 +456,22 @@ namespace DrinkRateAPI.Migrations name: "DbCompanyTableDbCompanyTableView"); migrationBuilder.DropTable( - name: "DbCompanyTableViewDbUser"); + name: "DbCompanyTableViewDbUserProfile"); migrationBuilder.DropTable( name: "DbProductTableDbProductTableView"); migrationBuilder.DropTable( - name: "DbProductTableViewDbUser"); + name: "DbProductTableViewDbUserProfile"); migrationBuilder.DropTable( name: "ProductRating"); migrationBuilder.DropTable( - name: "UserCompanyTableStats"); + name: "UserProfileCompanyTableStats"); migrationBuilder.DropTable( - name: "UserProductTableStats"); + name: "UserProfileProductTableStats"); migrationBuilder.DropTable( name: "CompanyTableViews"); @@ -445,7 +483,7 @@ namespace DrinkRateAPI.Migrations name: "Product"); migrationBuilder.DropTable( - name: "Users"); + name: "UserProfiles"); migrationBuilder.DropTable( name: "Companies"); @@ -453,6 +491,9 @@ namespace DrinkRateAPI.Migrations migrationBuilder.DropTable( name: "ProductTable"); + migrationBuilder.DropTable( + name: "ApplicationUsers"); + migrationBuilder.DropTable( name: "CompanyTables"); } diff --git a/DrinkRateAPI/Migrations/ApplicationDbContextModelSnapshot.cs b/DrinkRateAPI/Migrations/ApplicationDbContextModelSnapshot.cs index 7cc091a..68bd9d7 100644 --- a/DrinkRateAPI/Migrations/ApplicationDbContextModelSnapshot.cs +++ b/DrinkRateAPI/Migrations/ApplicationDbContextModelSnapshot.cs @@ -37,19 +37,19 @@ namespace DrinkRateAPI.Migrations b.ToTable("DbCompanyTableDbCompanyTableView"); }); - modelBuilder.Entity("DbCompanyTableViewDbUser", b => + modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b => { b.Property("CompanyTableViewsId") .HasColumnType("uuid"); - b.Property("UsersId") + b.Property("UserProfilesId") .HasColumnType("uuid"); - b.HasKey("CompanyTableViewsId", "UsersId"); + b.HasKey("CompanyTableViewsId", "UserProfilesId"); - b.HasIndex("UsersId"); + b.HasIndex("UserProfilesId"); - b.ToTable("DbCompanyTableViewDbUser"); + b.ToTable("DbCompanyTableViewDbUserProfile"); }); modelBuilder.Entity("DbProductTableDbProductTableView", b => @@ -67,19 +67,71 @@ namespace DrinkRateAPI.Migrations b.ToTable("DbProductTableDbProductTableView"); }); - modelBuilder.Entity("DbProductTableViewDbUser", b => + modelBuilder.Entity("DbProductTableViewDbUserProfile", b => { b.Property("ProductTableViewsId") .HasColumnType("uuid"); - b.Property("UsersId") + b.Property("UserProfilesId") .HasColumnType("uuid"); - b.HasKey("ProductTableViewsId", "UsersId"); + b.HasKey("ProductTableViewsId", "UserProfilesId"); - b.HasIndex("UsersId"); + b.HasIndex("UserProfilesId"); - b.ToTable("DbProductTableViewDbUser"); + b.ToTable("DbProductTableViewDbUserProfile"); + }); + + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b => + { + b.Property("Id") + .HasColumnType("text"); + + b.Property("AccessFailedCount") + .HasColumnType("integer"); + + b.Property("ConcurrencyStamp") + .HasColumnType("text"); + + b.Property("Email") + .HasColumnType("text"); + + b.Property("EmailConfirmed") + .HasColumnType("boolean"); + + b.Property("LockoutEnabled") + .HasColumnType("boolean"); + + b.Property("LockoutEnd") + .HasColumnType("timestamp with time zone"); + + b.Property("NormalizedEmail") + .HasColumnType("text"); + + b.Property("NormalizedUserName") + .HasColumnType("text"); + + b.Property("PasswordHash") + .HasColumnType("text"); + + b.Property("PhoneNumber") + .HasColumnType("text"); + + b.Property("PhoneNumberConfirmed") + .HasColumnType("boolean"); + + b.Property("SecurityStamp") + .HasColumnType("text"); + + b.Property("TwoFactorEnabled") + .HasColumnType("boolean"); + + b.Property("UserName") + .HasColumnType("text"); + + b.HasKey("Id"); + + b.ToTable("ApplicationUsers"); }); modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b => @@ -114,7 +166,7 @@ namespace DrinkRateAPI.Migrations modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompanyRating", b => { - b.Property("UserId") + b.Property("UserProfileId") .HasColumnType("uuid"); b.Property("CompanyId") @@ -126,7 +178,7 @@ namespace DrinkRateAPI.Migrations b.Property("Rating") .HasColumnType("smallint"); - b.HasKey("UserId", "CompanyId"); + b.HasKey("UserProfileId", "CompanyId"); b.HasIndex("CompanyId"); @@ -199,7 +251,7 @@ namespace DrinkRateAPI.Migrations modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProductRating", b => { - b.Property("UserId") + b.Property("UserProfileId") .HasColumnType("uuid"); b.Property("ProductId") @@ -211,7 +263,7 @@ namespace DrinkRateAPI.Migrations b.Property("Rating") .HasColumnType("smallint"); - b.HasKey("UserId", "ProductId"); + b.HasKey("UserProfileId", "ProductId"); b.HasIndex("ProductId"); @@ -247,12 +299,16 @@ namespace DrinkRateAPI.Migrations b.ToTable("ProductTableView"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUser", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b => { b.Property("Id") .ValueGeneratedOnAdd() .HasColumnType("uuid"); + b.Property("ApplicationUserId") + .IsRequired() + .HasColumnType("text"); + b.Property("IsAdmin") .HasColumnType("boolean"); @@ -265,13 +321,16 @@ namespace DrinkRateAPI.Migrations b.HasKey("Id"); + b.HasIndex("ApplicationUserId") + .IsUnique(); + b.HasIndex("UserName") .IsUnique(); - b.ToTable("Users"); + b.ToTable("UserProfiles"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserCompanyTableStat", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b => { b.Property("UserId") .HasColumnType("uuid"); @@ -292,10 +351,10 @@ namespace DrinkRateAPI.Migrations b.HasIndex("CompanyTableId"); - b.ToTable("UserCompanyTableStats"); + b.ToTable("UserProfileCompanyTableStats"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProductTableStat", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b => { b.Property("UserId") .HasColumnType("uuid"); @@ -316,7 +375,7 @@ namespace DrinkRateAPI.Migrations b.HasIndex("ProductTableId"); - b.ToTable("UserProductTableStats"); + b.ToTable("UserProfileProductTableStats"); }); modelBuilder.Entity("DbCompanyTableDbCompanyTableView", b => @@ -334,7 +393,7 @@ namespace DrinkRateAPI.Migrations .IsRequired(); }); - modelBuilder.Entity("DbCompanyTableViewDbUser", b => + modelBuilder.Entity("DbCompanyTableViewDbUserProfile", b => { b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTableView", null) .WithMany() @@ -342,9 +401,9 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", null) + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null) .WithMany() - .HasForeignKey("UsersId") + .HasForeignKey("UserProfilesId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); @@ -364,7 +423,7 @@ namespace DrinkRateAPI.Migrations .IsRequired(); }); - modelBuilder.Entity("DbProductTableViewDbUser", b => + modelBuilder.Entity("DbProductTableViewDbUserProfile", b => { b.HasOne("DrinkRateAPI.DbEntities.DbProductTableView", null) .WithMany() @@ -372,9 +431,9 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", null) + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", null) .WithMany() - .HasForeignKey("UsersId") + .HasForeignKey("UserProfilesId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); }); @@ -398,15 +457,15 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile") .WithMany("CompanyRatings") - .HasForeignKey("UserId") + .HasForeignKey("UserProfileId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Company"); - b.Navigation("User"); + b.Navigation("UserProfile"); }); modelBuilder.Entity("DrinkRateAPI.DbEntities.DbProduct", b => @@ -436,18 +495,29 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile") .WithMany("ProductRatings") - .HasForeignKey("UserId") + .HasForeignKey("UserProfileId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("Product"); - b.Navigation("User"); + b.Navigation("UserProfile"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserCompanyTableStat", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b => + { + b.HasOne("DrinkRateAPI.DbEntities.DbApplicationUser", "ApplicationUser") + .WithOne("UserProfile") + .HasForeignKey("DrinkRateAPI.DbEntities.DbUserProfile", "ApplicationUserId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("ApplicationUser"); + }); + + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileCompanyTableStat", b => { b.HasOne("DrinkRateAPI.DbEntities.DbCompanyTable", "CompanyTable") .WithMany() @@ -455,18 +525,18 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") - .WithMany("UserCompanyTableStats") + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile") + .WithMany("UserProfileCompanyTableStats") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("CompanyTable"); - b.Navigation("User"); + b.Navigation("UserProfile"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProductTableStat", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfileProductTableStat", b => { b.HasOne("DrinkRateAPI.DbEntities.DbProductTable", "ProductTable") .WithMany() @@ -474,15 +544,21 @@ namespace DrinkRateAPI.Migrations .OnDelete(DeleteBehavior.Cascade) .IsRequired(); - b.HasOne("DrinkRateAPI.DbEntities.DbUser", "User") - .WithMany("UserProductTableStats") + b.HasOne("DrinkRateAPI.DbEntities.DbUserProfile", "UserProfile") + .WithMany("UserProfileProductTableStats") .HasForeignKey("UserId") .OnDelete(DeleteBehavior.Cascade) .IsRequired(); b.Navigation("ProductTable"); - b.Navigation("User"); + b.Navigation("UserProfile"); + }); + + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbApplicationUser", b => + { + b.Navigation("UserProfile") + .IsRequired(); }); modelBuilder.Entity("DrinkRateAPI.DbEntities.DbCompany", b => @@ -507,15 +583,15 @@ namespace DrinkRateAPI.Migrations b.Navigation("Products"); }); - modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUser", b => + modelBuilder.Entity("DrinkRateAPI.DbEntities.DbUserProfile", b => { b.Navigation("CompanyRatings"); b.Navigation("ProductRatings"); - b.Navigation("UserCompanyTableStats"); + b.Navigation("UserProfileCompanyTableStats"); - b.Navigation("UserProductTableStats"); + b.Navigation("UserProfileProductTableStats"); }); #pragma warning restore 612, 618 }