title: Entity framework - Foreign key - data annotation
body: <p>I use Data annotation with EF and I have the classes:</p>
  
  <pre><code>[Table("Accounts")]
  public class DbAccount
  {
      public int Id { get; set; }
      public string Username { get; set; }
  
      public virtual DbLicense License { get; set; }
  }
  
  [Table("Licenses")]
  public class DbLicense
  {
      public int Id { get; set; }
      public int AccountId { get; set; }
  
      [ForeignKey("AccountId")]
      public virtual DbAccount Account { get; set; }
  }
  </code></pre>
  
  <p>How I must decorate the property <strong>public virtual DbLicense License { get; set; }</strong> ?</p>
  
  <p>EF throw </p>
  
  <p><strong>Unable to determine the principal end of an association between the types 'DbLicense' and 'DbAccount'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.</strong></p>
  
  <p>This work well:</p>
  
  <pre><code>modelBuilder.Entity&lt;DbAccount&gt;()
              .HasRequired(x =&gt; x.License)
              .WithRequiredPrincipal();
  </code></pre>
  
  <p>But how i can write this with annotation using?</p>