Reputation: 3
I am using Visual Studio 2015 and entity framework version 6.0.0.0 (code first), I've created a class as:
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace IRANMVCCore.Domain.Entity
{
public class UserProperty
{
[key]
[ForeignKey("Instructor")]
[Required(ErrorMessage = "error")]
public string Name { get; set; }
[Required(ErrorMessage = "error")]
public string Famil { get; set; }
[Required(ErrorMessage = "error")]
public string City { get; set; }
[Required(ErrorMessage = "error")]
public string Countries { get; set; }
}
}
Now I am getting this error:
Error CS0246 The type or namespace name 'ForeignKey' could not be found (are you missing a using directive or an assembly reference?)
I have reference : Refrances
How can I solved it?
Upvotes: 0
Views: 3850
Reputation: 3349
Add a reference to System.ComponentModel.DataAnnotations.Schema
as well.
Upvotes: 3
Reputation: 2020
1) To solve it check your reference version of:
System.ComponentModel.DataAnnotations
2) [key]
should be [Key]
Hope this helps anyone else
Upvotes: 0