Created
September 18, 2018 20:02
-
-
Save merken/16b6d6a2746acec63d186e915df555d3 to your computer and use it in GitHub Desktop.
OnModelCreating
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
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