I am making an application using MVC 3.0 Razor and Code First Entity Framework.
I am wondering how to define primary key and Foreign Key Relation in the Model.
I know how to define Primary Key.using Key attribute.
for example, I define [Key] attribute in the Model Table Class for Primary Key.
But, really don’t know how to define Foreign Key for column in class.
Please Help………………
I am making an application using MVC 3.0 Razor and Code First Entity Framework.
Share
You can just make a
List<ChildType>property in the parent class and aParentTypeproperty in the parent class.EF will generate the key automatically.