The RankId field is both an FK and a PK, but it is NOT an auto generated field.
I use this code to add row
var context = new ProjectContext();
Rank rank = new Rank
{
RankId = rankId,
Vote = vote
};
context.Ranks.Add(rank);
context.SaveChanges();
The error message is: {"Cannot insert the value NULL into column 'RankId', table 'MyProject.dbo.Rank'; column does not allow nulls. INSERT fails.\r\nThe statement has been terminated."}