title: Incorrect String Length in Entity Framework
body: <p>I'm using EF6 (Code First) in a project. </p>
  
  <p>By having below class:</p>
  
  <pre><code>public class State
  {
      public int ID { get; set; }
  
      [Required]
      [StringLength(10)]
      public string Code { get; set; }
  
      [Required]
      [StringLength(50)]
      public string Name { get; set; }
  
      [Required]
      public Country Country { get; set; }
  }
  </code></pre>
  
  <p>I expect to have <code>Code</code> as <code>nvarchar(10)</code> in database but I get <code>nvarchar(3)</code>. I see the correct length for <code>Name</code> column but can't figure out why <code>Code</code> is not created correctly.</p>
  
  <p>Edit:
  I have the Country class as below:</p>
  
  <pre><code>public class Country
  {
      [Key]
      [StringLength(3)]
      public string Code { get; set; }
  
  
      [Required]
      [StringLength(50)]
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>I think, EF thinks the Code in State class is the Code in Country class as there is association between them.</p>
  
  <p>Now, question is how should I tell EF that the Code in State class is not the Foreign Key to Country class?</p>