Map EF company table and table view
This commit is contained in:
parent
fe30203373
commit
10dd4c9b0d
3 changed files with 26 additions and 3 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -6,5 +6,5 @@ public class DbCompanyTable
|
|||
|
||||
public ICollection<DbCompany> Companies { get; set; }
|
||||
|
||||
public string CompanyTable { get; set; }
|
||||
public string CompanyTableName { get; set; }
|
||||
}
|
|
@ -6,5 +6,5 @@ public class DbProductTable
|
|||
|
||||
public ICollection<DbProduct> Products { get; set; }
|
||||
|
||||
public string ProductTable { get; set; }
|
||||
public string ProductTableName { get; set; }
|
||||
}
|
Loading…
Reference in a new issue