EF interprets a property as a foreign key property if it's named <navigation property name>+
<navigation property's primary key name> or <navigation property's primary key name>
for example,
public class Enrollment
{
public int EnrollmentID { get; set; }
public int StudentID { get; set; }
public virtual Student Student { get; set; }
}
we know that the primary key in Student class is ID,so the StudentID property satisfies the first pattern of two patterns mentioned above so it is the foreign key property.
on the other hand,if the primary key in Student class is StudentID,the StudentID property is still the foreign key since it satisfies the <navigation property's primary key name> pattern.
EF interprets a property as a foreign key property if it's named
<navigation property name>
+<navigation property's primary key name>
or<navigation property's primary key name>
for example,
we know that the primary key in Student class is ID,so the StudentID property satisfies the first pattern of two patterns mentioned above so it is the foreign key property.
on the other hand,if the primary key in Student class is StudentID,the StudentID property is still the foreign key since it satisfies the
<navigation property's primary key name>
pattern.