ASP Entity Framework Fluent API [ForeignKey] annotation error

Chilesat

New Member
I'm trying to set up a one to one relationship and ran into some issue with declaring an attribute as FK. I already searched and read some of the questions posted here but doesn't address my problem.\[code\]public class User{ [Key] public int userId {get;set;} [DisplayName("User Name")] [Required(ErrorMessage="User name required.")] public string username {get;set;} [DisplayName("Password")] [Required(ErrorMessage="Password required.")] [MinLength(6)] public string password {get;set;} [DisplayName("Email")] [Required(ErrorMessage="Email required.")] public string email {get;set;} public virtual List<RoleDetail> roleDetails { get; set; } public virtual Customer customer { get; set; }}public class Customer{ [Key] public int cusomterId { get; set; } [DisplayName("First Name")] [Required(ErrorMessage="First name required.")] public string firstname {get;set;} [DisplayName("Last Name")] [Required(ErrorMessage="Last name required.")] public string lastname {get;set;} [ForeignKey("userId")] public int userId {get;set;}}\[/code\]I'm getting this error when I use the [ForeignKey] annotation. And I'm using System.ComponentModel.DataAnnotations. Also, [Key] works fine.\[code\]The type or namespace name 'ForeignKeyAttribute' could not be found (are you missing a using directive or an assembly reference?) \[/code\]What am I missing here?
 
Back
Top