Last active
March 15, 2018 03:25
-
-
Save josephhhhh/52edc7c5c66b8cda819b03932f604c80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace CascadeDelete.Models | |
{ | |
public class DataContext: DbContext | |
{ | |
public virtual DbSet<Resident> Residents { get; set; } | |
public virtual DbSet<City> Cities { get; set; } | |
public virtual DbSet<ResidentCityOwn> ResidentCityOwn { get; set; } | |
protected override void OnModelCreating(DbModelBuilder modelBuilder) | |
{ | |
// Fluent API configurations | |
modelBuilder.Entity<Resident>() | |
.HasRequired(e => e.City) | |
.WithMany(e => e.Residents) | |
.WillCascadeOnDelete(false); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment