using System; using Microsoft.EntityFrameworkCore; namespace EntityFrameworkCore.Jet.IntegrationTests.Model28 { public class Context : DbContext { public Context(DbContextOptions options) : base (options) { } public DbSet Advertisements { get; set; } public DbSet Users { get; set; } public DbSet AdImages { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity() .HasMany(u => u.Advertisements) .WithOne(x => x.User) .IsRequired() ; modelBuilder.Entity() .HasMany(a => a.AdImages) .WithOne(x => x.Advertisement) .IsRequired() ; // Is required must be inserted in foreign key field if there is one /* modelBuilder.Entity() .Property(x => x.Advertisement) .IsRequired() ; */ base.OnModelCreating(modelBuilder); } } }