title: Best approach for my EF 'DataBase'
body: <p>I've been a few weeks working on a web project, amd mostly thinking how would I implement data layer. I chosed Entity Framework 4.1, code first model.</p>
  
  <p>So, among lot of other entities , think of PLAYER who has N CHARACTER, that can be in 0..1 GUILD</p>
  
  <pre><code>public class Player
  {
      public int Id { get; set; }
      public string Login { get; set; }
      public string Password { get; set; }
      public bool IsLogged { get; set; }
      public DateTime LastActivity { get; set; }
      public DateTime LastLogin { get; set; }
      public DateTime LastLogout { get; set; }
      public string DisplayName { get; set; }
      public string DefaultImage { get; set; }
  
      public virtual Board Board { get; set; }
      public virtual PlayerData PlayerData { get; set; }
      public virtual ICollection&lt;Character&gt; Characters { get; set; }
  }
  public class Guild
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public string DefaultImage { get; set; }
  
      public virtual ICollection&lt;Character&gt; Characters { get; set; }
  }
  public class Character
  {
      public int Id { get; set; }
      public string Name { get; set; }
  
      public virtual Player Player { get; set; }
      public virtual Guild Guild { get; set; }
      public virtual GuildRank GuildRank { get; set; }
      public virtual Game Game { get; set; }
  }
  </code></pre>
  
  <p>As you can see, there a lot more entities and relationships, but this will work.</p>
  
  <p>Well it does not, this code:</p>
  
  <pre><code>Character character = mod.Characters.Where(c =&gt; c.Player == player).FirstOrDefault();
  </code></pre>
  
  <p>Throws an exception: </p>
  
  <blockquote>
    <p>Unable to create a constant value of type 'DataObjects.Player'. Only
    primitive types ('such as Int32, String, and Guid') are supported in
    this context.</p>
  </blockquote>
  
  <p>I don't understand why.</p>
  
  <p>I also tried with using [Key] and [ForeingKey] attributes, but I can't find them! :S (though the where in System.Data.Entity.dll, but the don't).</p>
  
  <p>So after so many errors, I started to think maybe I got the whole thing wrong...</p>
  
  <p>Any ideas on how to fix the error, or to go in other direction?</p>
  
  <p>Thanks in advance.</p>