https://www.learnentityframeworkcore.com/configuration/fluent-api/type-configuration how to use? protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(typeof(EntityName))... } protected override void OnMod
https://www.learnentityframeworkcore.com/configuration/fluent-api/type-configuration
how to use?
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity(typeof(EntityName))... }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity("EntityName")... }
protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<EntityName>()... }
example
public class SampleContext : DbContext { public DbSet<Order> Orders { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Order>() .HasKey(o => o.OrderNumber); } } public class Order { public int OrderNumber { get; set; } public DateTime DateCreated { get; set; } public Customer Customer { get; set; } ... )
public class SampleContext : DbContext { public DbSet<Order> Orders { get; set; } protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Order>() .HasKey(o => new { o.CustomerAbbreviation, o.OrderNumber }); } }