Updating Asp.net MVC to Core

public class Client { [Key] [ForeignKey("Virtual_KEY")] [Column(Order = 0)] public int Id { get; set; } [Key] [Column(Order = 1)] public string Id2 { get; set; } 

Entity type 'Client' has a composite key that has been defined with data annotations. To set a composite primary key, use fluent API.

  • So here is the answer - the composite key is set via Fluent API - Mikhail M
  • so it is generated automatically, and after updating models, changes will be lost? More through Column (Order will not work? - codename0082016
  • unfortunately Core has its limitations - Mikhail M
  • and where to read why changed? - codename0082016

1 answer 1

 protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.Entity<Client>() .HasKey(c => new { c.Id, c.Id2 }); }