Entity Framework Primary Key Convention


By default a property is a primary key if a property on a class is named “ID” (not case sensitive), or the class name followed by "ID". If the type of the primary key property is numeric or GUID it will be configured as an identity column. Simple Example:

public class Room
    // Primary key 
    public int RoomId{ get; set; }