I am using code first approach to create database.
Then i am try to Update Database in Package console Manger using
Update-Database -Verbose command error show :-
The navigation property 'UserId' is not a declared property on type 'User'. Verify that it has not been explicitly excluded from the model and that it is a valid navigation property.
[Table("UserProfile")]
public class UserProfile
{
[Key]
[DatabaseGeneratedAttribute(DatabaseGeneratedOption.Identity)]
public int UserId { get; set; }
public string UserName { get; set; }
public virtual ICollection<User> Usera { get; set; }
}
public class User
{
[Key]
public long u_ID { get; set; }
//public int UserId { get; set; }
[Required(ErrorMessage = "Please Enter Headline name ")]
[Display(Name = "Headline Profile")]
public string head_profile { get; set; }
[Required(ErrorMessage = "Please Enter Full Name")]
[Display(Name = "Full Name:")]
public string full_name { get; set; }
[ForeignKey("UserId")]
public int UserId { get; set; }
public virtual UserProfile UserProfilefk { get; set; }
}
How to Create Foreign key