Late answer here. If you can add a Key - you should. EntityFramework uses it internally. I've seen issues - If you have 2 or more identical rows, it'll only come back once. If that's not an option, You need to make an in-memory composite key. You can do this via the Fluent API in the DbContext or in the class mapping.
Option #1:
In your DbContext to make an in-memory composite key with the Fluent API:
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<YOUR_TABLE>()
.HasKey(c => new { c.Column1, c.Column2, c.Column3, etc. });
}
Option #2:
Same thing but with attributes in EF Object Mapping.
public class TableName
{
[Key]
[Column(Order = 0)]
public int Column1 { get; set; }
[Key]
[Column(Order = 1)]
public int? Column2 { get; set; }
[Key]
[Column(Order = 2)]
public int Column3 { get; set; }
}
Option #3:
If you're in EF Core 3.0+ use the fluent API:
modelBuilder
.Entity<YourEntityType>(eb =>
{
eb.HasNoKey();
});
Option #5:
If you're in EF Core 5.0+ you can do it directly in the EF Object Mapping
[Keyless]
public class TableName
{
[Key]
[Column(Order = 0)]
public int Column1 { get; set; }
[Key]
[Column(Order = 1)]
public int? Column2 { get; set; }
[Key]
[Column(Order = 2)]
public int Column3 { get; set; }
}