Entity Framework: Set Delete Rule with CodeFirst

What you are looking for can be achieved by setting up an optional association between Guest and Language entities: protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Guest>() .HasOptional(p => p.PreferredLanguage) .WithMany() .HasForeignKey(p => p.LanguageID); } Unit Test: using (var context = new Context()) { var language = new Language() { LanguageName = “en” }; var guest … Read more

Using mvc-mini-profiler database profiling with Entity Framework Code First

This is now fully supported, check out the latest source or grab the package from nuget. You will need the MiniProfiler.EF package if you are using nuget. (1.9.1 and up) Supporting this involved a large set of modifications to the underlying proxy object to support acting as EF code first proxies. To add this support: … Read more