I am busy learning ASP.Net MVC and so I recently installed MVC 4 on Visual Studio 2010 Professional. I was trying this example:
http://www.luisrocha.net/2010/11/creating-composite-keys-using-code.html
But the RelatedTo attribute is not found by Visual Studio. I read on this question that this could be caused by Entity Framework 4.1 not being installed. I checked the version number of System.Data.Entity.dll and it gave version 4.0.0.0, runtime version v4.0.30319. So this seems to me to be version 4.0 of EF that is installed on my computer. I may be wrong on this though... so someone please correct me if I am.
I downloaded EF 4.1 from here and installed it, but the version numbers for System.Data.Entity.dll seem not to have changed and the RelatedTo attribute is still not working. Anyone know what is going wrong with the installation and how I could fix it?
UPDATE:
I installed Entity Framework using nuget as instructed on this site, and the console said it installed EntityFramework 5.0.0-rc, but the version of System.Data.Entity.dll seems to be unchanged.
No, I did not include using System.Data.Entity because intellisense did not tell me to include that. I did include System.ComponentModel.DataAnnotations and using System.ComponentModel.DataAnnotations.Schema because these were required by the Key and Column attributes. Intellisense asks me to "Generate class for 'RelatedTo'" and adding using System.Data.Entity does not change that.
Here is my code for those asking for it, although it is exactly the code from the tutorial that I linked to in the question:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity;
namespace Example
{
public class PlaylistTrack
{
[Key, Column(Order = 1)]
public int PlaylistId { get; set; }
[Key, Column(Order = 2)]
public int TrackId { get; set; }
[RelatedTo(ForeignKey = "PlaylistId")]
public Playlist Playlist { get; set; }
[RelatedTo(ForeignKey = "TrackId")]
public Track Track { get; set; }
}
}