Part 15 Conditional Mapping in entity framework with code first04:33

  • 0
Published on January 7, 2018

Link for all dot net and sql server video tutorial playlists

Link for slides, code samples and text version of the video

In Part 14, we discussed Conditional Mapping in entity framework with database first approach. Please watch Part 14 before proceeding. In this video we will discuss Conditional Mapping in entity framework with code first approach.

To implement Conditional Mapping with code first override OnModelCreating() method
using System.Data.Entity;
namespace Demo
{
public class EmployeeDBContext : DbContext
{
public DbSet[Employee] Employees { get; set; }

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity[Employee]()
.Map(m =] m.Requires(“IsTerminated”)
.HasValue(false))
.Ignore(m =] m.IsTerminated);

base.OnModelCreating(modelBuilder);
}
}
}

https://cafeadobro.ro/

https://www.stagebox.uk/wp-includes/depo10-bonus10/

https://iavec.com.br/

Enjoyed this video?
"No Thanks. Please Close This Box!"