I am trying to use Entity Framework on my web site. I followed tutorials and Visual Studio (2010) does not complain. However, when I add a ForeignKey data annotation, I get an error when I run on the web site that the Namespace does not exist.
CS0246: The type or namespace name 'ForeignKey' could not be found (are you missing a using directive or an assembly reference?)
After doing some searching, it appears that the ForeignKey data annotation does not exist in .NET 4.
If that is the case, is there a way to add at foreign key to the model in .NET 4?Answer1:
Correct, System.ComponentModel.DataAnnotations.Schema is part of .NET 4.5.
Have you instead looked at the Fluent API?
Here's a video for VS 2010 specifically. <a href="http://msdn.microsoft.com/en-ca/data/gg194009.aspx" rel="nofollow">http://msdn.microsoft.com/en-ca/data/gg194009.aspx</a>