Compare commits
No commits in common. "0a4c4abcbcb3e8677ba7c2ad22b33caac9fcfef4" and "855e9a4bcf1a7adbad60a4ed0a15d8de537a9790" have entirely different histories.
0a4c4abcbc
...
855e9a4bcf
1 changed files with 0 additions and 64 deletions
|
@ -90,70 +90,6 @@ public class ApplicationDbContext : DbContext
|
|||
entity.HasMany(ctv => ctv.Users)
|
||||
.WithMany(u => u.CompanyTableViews);
|
||||
});
|
||||
|
||||
// Product
|
||||
modelBuilder.Entity<DbProduct>(entity =>
|
||||
{
|
||||
entity.HasKey(p => p.Id);
|
||||
|
||||
entity.HasOne(p => p.ProductTable)
|
||||
.WithMany(pt => pt.Products)
|
||||
.HasForeignKey(p => p.ProductTableId);
|
||||
|
||||
entity.HasOne(p => p.Company)
|
||||
.WithMany(c => c.Products)
|
||||
.HasForeignKey(p => p.CompanyId);
|
||||
|
||||
entity.HasMany(p => p.ProductRatings)
|
||||
.WithOne(pr => pr.Product)
|
||||
.HasForeignKey(pr => pr.ProductId);
|
||||
|
||||
entity.Property(p => p.ProductName)
|
||||
.IsRequired()
|
||||
.HasMaxLength(50);
|
||||
|
||||
entity.HasIndex(c => c.ProductName)
|
||||
.IsUnique();
|
||||
|
||||
// to do: index by Sum / Count
|
||||
});
|
||||
|
||||
// Product Rating
|
||||
modelBuilder.Entity<DbProductRating>(entity =>
|
||||
{
|
||||
entity.HasKey(pr => new { pr.UserId, pr.ProductId });
|
||||
|
||||
entity.HasOne(pr => pr.User)
|
||||
.WithMany(u => u.ProductRatings);
|
||||
|
||||
entity.HasOne(pr => pr.Product)
|
||||
.WithMany(p => p.ProductRatings);
|
||||
});
|
||||
|
||||
// Product Table
|
||||
modelBuilder.Entity<DbProductTable>(entity =>
|
||||
{
|
||||
entity.HasKey(pt => pt.Id);
|
||||
|
||||
entity.HasMany(pt => pt.Products)
|
||||
.WithOne(p => p.ProductTable)
|
||||
.HasForeignKey(p => p.ProductTableId);
|
||||
|
||||
entity.HasIndex(pt => pt.ProductTableName)
|
||||
.IsUnique();
|
||||
});
|
||||
|
||||
// Product Table View
|
||||
modelBuilder.Entity<DbProductTableView>(entity =>
|
||||
{
|
||||
entity.HasKey(ptv => ptv.Id);
|
||||
|
||||
entity.HasMany(ptv => ptv.ProductTables)
|
||||
.WithMany();
|
||||
|
||||
entity.HasMany(ptv => ptv.Users)
|
||||
.WithMany(u => u.ProductTableViews);
|
||||
});
|
||||
|
||||
// User
|
||||
modelBuilder.Entity<DbUser>(entity =>
|
||||
|
|
Loading…
Reference in a new issue