Skip to content

Instantly share code, notes, and snippets.

@DannyRusnok
Last active January 7, 2022 16:14
Show Gist options
  • Save DannyRusnok/5fc50a2bbb78e9ed25c692cae18c2129 to your computer and use it in GitHub Desktop.
Save DannyRusnok/5fc50a2bbb78e9ed25c692cae18c2129 to your computer and use it in GitHub Desktop.
Value Objects Article
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