title: integer or string key field (in MVC application)
body: <p>My question comes up developing one of my first c# MVC applications with Entity Framework Code First, but I think it is pretty general.</p>
  
  <p>I saw a lot of examples where a table with countries is defined with an integer countryID as primary key, something like this:</p>
  
  <pre><code>public class Country
  {
      int CountryID {get;set;}
      [Required]
      [MaxLength(3, ErrorMessage = "Country cannot be over 3 characters")]
      [MinLength(1, ErrorMessage = "Country must be filled")]
      string Code {get;set;}
      [Required]
      [MaxLength(25, ErrorMessage = "Description cannot be over 25 characters")]
      [MinLength(1, ErrorMessage = "Description must be filled")]
      string Description {get;set;}
  }
  </code></pre>
  
  <p>But, since the country code will never change, it could be the primary key, something like this:</p>
  
  <pre><code>public class Country
  {
      [Required]
      [MaxLength(3, ErrorMessage = "Country cannot be over 3 characters")]
      [MinLength(1, ErrorMessage = "Country must be filled")]
      string CountryID {get;set;}
      string Description {get;set;}
  }
  </code></pre>
  
  <p>Logically, I think the primary key should be the countrycode, but there might be reasons to never use a string as primary key. (performance?)
  Is there a reason, why this is normally not done this way? Will I run into problems later if I do use the code as primary key? The same goes for tables like salesorders, shipment ID's etc, where the identifying column will never change.</p>