Entity framework core composite primary key attribute
public class UsersData
{
[CompositeKey]
public Guid UserId{ get; set; }
[CompositeKey]
[Required]
public string DataId { get; set; }
}
public class MyDbContext : DbContext
{
...
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
...
modelBuilder.BindCompositeKey();
}
}