Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7985497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:34:25+00:00 2026-06-04T11:34:25+00:00

I am busy learning ASP.Net MVC and so I recently installed MVC 4 on

  • 0

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; }
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T11:34:26+00:00Added an answer on June 4, 2026 at 11:34 am

    Try installing new version of EF using Nuget. It will resolve all dependencies of EF and it will make sure you have the latest version. I don’t know what is RelatedTo attribute supposed to be doing here. And see here in the data annotations section, the related to attribute is not in the EF4.1 release. But you can do the same thing like this.

          [ForeignKey("PlaylistId")] 
          public Playlist Playlist { get; set; }
    
          [ForeignKey("TrackId")] 
          public Track Track { get; set; }
    

    EDIT
    RelatedTo attribute is replaced by ForeignKey and InverseProperty attributes in EF 4.1 RC

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am busy working with an ASP.NET MVC 3 application and using Windows 7.
Busy working on Visual Studio 2010 Express for Windows phone and is wanting to
How do I get the Silverlight Add-On for Visual Studio 2010? And where can
Busy learning Ruby... the documentation have an example: hello world.count(lo, o) that return 2
I am busy climbing the learning curve for OpenGL, using Delphi (pascal); I am
I'm busy learning how to build apps for Android, and I come across a
I am busy working on this and thought I would put it our there.
Im busy for a while now solving the following issue: I have a http://domain.com
I'm currently busy coding a hangman game in VB.NET. As a wordlist, I have
I'm busy learning Common Lisp, & I'm looking for a static code analysis tool

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.