title: ASP.NET MVC are two foreign fields in dependent class of One to Many relationship legal
body: <p>I have a problem with relationships in ASP.NET MVC. I have two models that have a one to many relationship. On the dependent class), the other class has two fields. I know that the dependent class applies the foreign attribute to establish a relationship. In my dependent class, am unsure if I should use to ForeignKey attributes to point to the other class. This is as per <a href="http://www.asp.net/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-a-more-complex-data-model-for-an-asp-net-mvc-application" rel="nofollow">this tutorial on MVC site</a> </p>
  
  <p>Here is a simplified example of my problem.</p>
  
  <pre><code>public class Location {
      //Other fields here.
      public List&lt;Link&gt; Links{get; set;}
  }
  
  // dependent class
  public class Link {
      //Other fields here...
  
      [ForeignKey("Location")]
      public string StartingLocation { get; set;}
  
      [ForeignKey("Location")]
      public string EndingLocation { get; set;}
  
      public Location Location  { get; set;}
  }
  </code></pre>
  
  <p>Is what am doing on my dependent class legal and if so is it recommended? </p>
  
  <p>Thanks and regards.</p>