title: How do i define Keys when working with "EF-Code First"?
body: <p>I get a ModelValidationException (at the bottom) when working with "EF-Code First". It wants me to define a Key but I'm not sure what exactly it means...</p>
  
  <pre><code>public class Unit
  {
      Guid id;
      String public_id;
      String name;        
      bool deleted;
  }
  
  public class MyDataContext : DbContext
  {
      public DbSet&lt;Unit&gt; Units { get; set; }
  
      protected override void OnModelCreating(ModelBuilder modelBuilder)
      {
          modelBuilder.Entity&lt;Unit&gt;().ToTable("sometable");
      }
  }
  
  [TestFixture]
  public class DataTests
  {
      [Test]
      public void Test()
      {
          MyDataContext database = new MyDataContext();
          var o = database.Units;
  
  
          Console.WriteLine(o.Count()); // This line throws!
          Assert.IsTrue(true);
      }
  }
  </code></pre>
  
  <blockquote>
    <p>System.Data.Entity.ModelConfiguration.ModelValidationException : One or more validation errors were detected during model generation:</p>
    
    <p>System.Data.Edm.EdmEntityType: : EntityType 'Unit' has no key defined. Define the key for this EntityType.</p>
    
    <p>System.Data.Edm.EdmEntitySet: EntityType: The EntitySet Units is based on type Unit that has no keys defined.</p>
  </blockquote>