Last active
January 7, 2022 16:14
-
-
Save DannyRusnok/5fc50a2bbb78e9ed25c692cae18c2129 to your computer and use it in GitHub Desktop.
Value Objects Article
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
public class AppDbContext : DbContext | |
{ | |
public AppDbContext(DbContextOptions<AppDbContext> options) : base(options) | |
{ | |
} | |
protected override void ConfigureConventions(ModelConfigurationBuilder configurationBuilder) | |
{ | |
configurationBuilder.Properties<Address>().HaveConversion<AddressConverter>(); | |
} | |
protected override void OnModelCreating(ModelBuilder modelBuilder) | |
{ | |
modelBuilder.Entity<Person>(b => | |
{ | |
b.ToTable("Persons").HasKey(x => x.Id); | |
b.Property(x => x.Name) | |
.HasMaxLength(255) | |
.HasDefaultValue(string.Empty); | |
b.Property(x => x.LastName) | |
.HasMaxLength(255) | |
.HasDefaultValue(string.Empty); | |
b.Property(e => e.Address); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment