Skip to content

Instantly share code, notes, and snippets.

@merken
Created September 18, 2018 20:02
Show Gist options
  • Save merken/16b6d6a2746acec63d186e915df555d3 to your computer and use it in GitHub Desktop.
Save merken/16b6d6a2746acec63d186e915df555d3 to your computer and use it in GitHub Desktop.
OnModelCreating
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Customer>()
.ToTable("DimCustomer");
modelBuilder.Entity<Customer>()
.HasKey("CustomerKey");
modelBuilder
.Entity<Customer>()
.Property(c => c.BirthDay)
.HasColumnName("BirthDate")
.HasConversion(
birthDay => new DateTime(birthDay.Year, birthDay.Month, birthDay.DayOfMonth),
birthDate => new BirthDay
{
Year = birthDate.Year,
Month = birthDate.Month,
DayOfMonth = birthDate.Day,
});
base.OnModelCreating(modelBuilder);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment