How to Create Foreign key ??

vishal patil

vishal patil

Feb 1 2015 2:48 AM
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.

    public class UserProfile
        public int UserId { get; set; }
        public string UserName { get; set; }

          public virtual ICollection<User> Usera { get; set; }

  public class User
        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; }
        public int UserId { get; set; }

        public virtual UserProfile UserProfilefk { get; set; }

How to Create Foreign key

Answers (1)
Next Recommended Forum