i have these two models
public class Group
{
[Key]
public int GroupID { get; set; }
[Required]
public string GroupName { get; set; }
}
public class User
{
[Key]
public int UserID { get; set; }
[Required]
[StringLength(20)]
public string UserName { get; set; }
[Required]
public string Password { get; set; }
public virtual Group Groups { get; set; }
}
using code first approach it creates Groups_GroupID as the foreign key in the user table when it generates the database. Specifying GroupID with displayname didn’t work either because it is creating the same name.so how would i make it generate GroupID in the User Table? i am using EF 4.3
Use the ForeignKey attribute on the navigational property