Answers for "The entity type has multiple properties with the [Key] attribute."

C#
0

The entity type has multiple properties with the [Key] attribute.

public class NorthwindContext : DbContext
{
     public NorthwindContext(DbContextOptions<NorthwindContext> options):base(options) { }

     public NorthwindContext() { }

     protected override void OnModelCreating(ModelBuilder builder)
     {
         builder.Entity<Relationship>().HasKey(table => new {
         table.FriendId, table.UserId
         });
     }
     public DbSet<Relationship> Relationships { get; set; }
     public DbSet<User> Users { get; set; }
}
Posted by: Guest on November-28-2020

Code answers related to "The entity type has multiple properties with the [Key] attribute."

C# Answers by Framework

Browse Popular Code Answers by Language