Setup base EF model and authentication #1

Merged
Jiri merged 17 commits from EntityFrameworkSetup into main 2025-08-09 17:20:48 +00:00
3 changed files with 26 additions and 3 deletions
Showing only changes of commit 10dd4c9b0d - Show all commits

View file

@ -66,6 +66,29 @@ public class ApplicationDbContext : DbContext
.WithMany(c => c.CompanyRatings);
});
// to do: othe objects
// Company Table
modelBuilder.Entity<DbCompanyTable>(ct =>
{
ct.HasKey(ct => ct.Id);
ct.HasMany(ct => ct.Companies)
.WithOne(c => c.CompanyTable)
.HasForeignKey(c => c.CompanyTableId);
ct.HasIndex(ct => ct.CompanyTableName)
.IsUnique();
});
// Company Table View
modelBuilder.Entity<DbCompanyTableView>(ctv =>
{
ctv.HasKey(ctv => ctv.Id);
ctv.HasMany(ctv => ctv.CompanyTables)
.WithMany();
ctv.HasMany(ctv => ctv.Users)
.WithMany(u => u.CompanyTableViews);
});
}
}

View file

@ -6,5 +6,5 @@ public class DbCompanyTable
public ICollection<DbCompany> Companies { get; set; }
public string CompanyTable { get; set; }
public string CompanyTableName { get; set; }
}

View file

@ -6,5 +6,5 @@ public class DbProductTable
public ICollection<DbProduct> Products { get; set; }
public string ProductTable { get; set; }
public string ProductTableName { get; set; }
}