Watch Part 11 Entity splitting in entity framework with code first approach in New Channel | Channify

c-2lATYsrPSCf7cdRW 3287424 8iWnjiXpCL0
Views
Likes
Comments
Published May 21, 2014
Channel kudvenkat

Add More Videos To your Channel

Text version of the video http://csharp-video-tutorials.blogspot.com/2014/05/part-11-entity-splitting-in-entity.html Slides http://csharp-video-tutorials.blogspot.com/2014/05/part-11-entity-splitting-in-entity_21.html Entity Framework - All Text Articles http://csharp-video-tutorials.blogspot.com/2014/05/entity-framework-tutorial.html Entity Framework - All Slides http://csharp-video-tutorials.blogspot.com/2014/05/entity-framework-tutorial-slides.html Entity Framework Playlist https://www.youtube.com/playlist?list=PL6n9fhu94yhUPBSX-E2aJCnCR3-_6zBZx Dot Net, SQL, Angular, JavaScript, jQuery and Bootstrap complete courses https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd Entity splitting refers to mapping an entity to two or more tables when the tables share a common key. We discussed, Entity splitting with database first approach in Part 10 By default, Entity Framework code-first creates one Employees table based on Employee class To map the Employee entity to 2 tables -- Employees & EmployeeContactDetails, override OnModelCreating() method of the DBContext class public class EmployeeDBContext : DbContext { public DbSet[Employee] Employees { get; set; } protected override void OnModelCreating(DbModelBuilder modelBuilder) { modelBuilder.Entity[Employee]() // Specify properties to map to Employees table .Map(map =] { map.Properties(p =] new { p.EmployeeId, p.FirstName, p.LastName, p.Gender }); map.ToTable("Employees"); }) // Specify properties to map to EmployeeContactDetails table .Map(map =] { map.Properties(p =] new { p.EmployeeId, p.Email, p.Mobile, p.Landline }); map.ToTable("EmployeeContactDetails"); }); base.OnModelCreating(modelBuilder); } }