SHOW:
|
|
- or go back to the newest paste.
| 1 | public class MyYobaContext : DbContext, IMyYobaContext {
| |
| 2 | public DbSet<SmallYoba> { get; set; }
| |
| 3 | public DbSet<BigYoba> { get; set; }
| |
| 4 | public DbSet<SmallBigYoba> { get; set; }
| |
| 5 | ||
| 6 | protected override void OnModelCreating(ModelBuilder modelBuilder) | |
| 7 | {
| |
| 8 | modelBuilder.Entity<SmallBigYoba>() | |
| 9 | .HasKey(option => new { option.SmallYobaId, option.BigYobaId });
| |
| 10 | base.OnModelCreating(modelBuilder); | |
| 11 | base.OnModelCreating(modelBuilder); | |
| 12 | } | |
| 13 | } | |
| 14 | ||
| 15 | public class SmallBigYoba {
| |
| 16 | public int SmallYobaId { get; set; }
| |
| 17 | public SmallYoba SmallYoba { get; set; }
| |
| 18 | ||
| 19 | public int BigYobaId { get; set; }
| |
| 20 | public BigYoba BigYoba { get; set; }
| |
| 21 | } | |
| 22 | ||
| 23 | public class BigYoba {
| |
| 24 | ... | |
| 25 | ICollection<SmallBigYoba> ManyToManyYoba { get; set; }
| |
| 26 | ... | |
| 27 | } | |
| 28 | ||
| 29 | public class SmallYoba {
| |
| 30 | ... | |
| 31 | ICollection<SmallBigYoba> ManyToManyYoba { get; set; }
| |
| 32 | ... | |
| 33 | } |