Change property name for consistency
This commit is contained in:
parent
10dd4c9b0d
commit
aefaac9140
1 changed files with 18 additions and 18 deletions
|
@ -32,62 +32,62 @@ public class ApplicationDbContext : DbContext
|
|||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
// Company
|
||||
modelBuilder.Entity<DbCompany>(c =>
|
||||
modelBuilder.Entity<DbCompany>(entity =>
|
||||
{
|
||||
c.HasKey(c => c.Id);
|
||||
entity.HasKey(c => c.Id);
|
||||
|
||||
c.HasMany(c => c.Products)
|
||||
entity.HasMany(c => c.Products)
|
||||
.WithOne(p => p.Company)
|
||||
.HasForeignKey(p => p.CompanyId);
|
||||
|
||||
c.HasMany(c => c.CompanyRatings)
|
||||
entity.HasMany(c => c.CompanyRatings)
|
||||
.WithOne(cr => cr.Company)
|
||||
.HasForeignKey(cr => cr.CompanyId);
|
||||
|
||||
c.Property(c => c.CompanyName)
|
||||
entity.Property(c => c.CompanyName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
c.HasIndex(c => c.CompanyName)
|
||||
entity.HasIndex(c => c.CompanyName)
|
||||
.IsUnique();
|
||||
|
||||
// to do: index by Sum / Count
|
||||
});
|
||||
|
||||
// Company Rating
|
||||
modelBuilder.Entity<DbCompanyRating>(cr =>
|
||||
modelBuilder.Entity<DbCompanyRating>(entity =>
|
||||
{
|
||||
cr.HasKey(cr => new { cr.UserId, cr.CompanyId });
|
||||
entity.HasKey(cr => new { cr.UserId, cr.CompanyId });
|
||||
|
||||
cr.HasOne(cr => cr.User)
|
||||
entity.HasOne(cr => cr.User)
|
||||
.WithMany(u => u.CompanyRatings);
|
||||
|
||||
cr.HasOne(cr => cr.Company)
|
||||
entity.HasOne(cr => cr.Company)
|
||||
.WithMany(c => c.CompanyRatings);
|
||||
});
|
||||
|
||||
// Company Table
|
||||
modelBuilder.Entity<DbCompanyTable>(ct =>
|
||||
modelBuilder.Entity<DbCompanyTable>(entity =>
|
||||
{
|
||||
ct.HasKey(ct => ct.Id);
|
||||
entity.HasKey(ct => ct.Id);
|
||||
|
||||
ct.HasMany(ct => ct.Companies)
|
||||
entity.HasMany(ct => ct.Companies)
|
||||
.WithOne(c => c.CompanyTable)
|
||||
.HasForeignKey(c => c.CompanyTableId);
|
||||
|
||||
ct.HasIndex(ct => ct.CompanyTableName)
|
||||
entity.HasIndex(ct => ct.CompanyTableName)
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
// Company Table View
|
||||
modelBuilder.Entity<DbCompanyTableView>(ctv =>
|
||||
modelBuilder.Entity<DbCompanyTableView>(entity =>
|
||||
{
|
||||
ctv.HasKey(ctv => ctv.Id);
|
||||
entity.HasKey(ctv => ctv.Id);
|
||||
|
||||
ctv.HasMany(ctv => ctv.CompanyTables)
|
||||
entity.HasMany(ctv => ctv.CompanyTables)
|
||||
.WithMany();
|
||||
|
||||
ctv.HasMany(ctv => ctv.Users)
|
||||
entity.HasMany(ctv => ctv.Users)
|
||||
.WithMany(u => u.CompanyTableViews);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue