title: Entity Framework 4.1 Code First and One-to-Many mapping problem
body: <p>I have problem with mapping existing database.</p>
  
  <p>2 tables (simplified)</p>
  
  <pre><code>"SomeEntity"
  Id int
  Name nvarchar
  </code></pre>
  
  <p>and</p>
  
  <pre><code>"EntityProperty"
  EntityId int
  Name nvarchar
  </code></pre>
  
  <p>and have relation one-to-many from Entity to entity properties.</p>
  
  <p>How I can map this using EF 4.1 Code First?</p>
  
  <p>Thx in advance.</p>
  
  <p><strong>Edited 1:</strong></p>
  
  <p>ok) this is my code</p>
  
  <pre><code>class Program
      {
          static void Main(string[] args)
          {
              var context = new DataContext();
  
              var result = context.SomeEntity.Include(p =&gt; p.EntityProperties);
  
              foreach (var entity in result)
              {
                  Console.WriteLine(entity);
              }
  
          }
      }
  
      public class SomeEntity
      {
          public int EntityId { get; set; }
          public string Name { get; set; }
          public virtual ICollection&lt;EntityProperty&gt; EntityProperties { get; set; }
  
          public override string ToString()
          {
              return string.Format("Id: {0}, Name: {1}", EntityId, Name);
          }
      }
  
      public class EntityProperty
      {
          public int EntityId { get; set; }
          public string Name { get; set; }
      }
  
      public class DataContext : DbContext
      {
          public DbSet&lt;SomeEntity&gt; SomeEntity { get { return this.Set&lt;SomeEntity&gt;(); } }
  
          protected override void OnModelCreating(DbModelBuilder modelBuilder)
          {
              modelBuilder.Entity&lt;SomeEntity&gt;().ToTable("SomeEntity");
              modelBuilder.Entity&lt;SomeEntity&gt;().HasKey(k =&gt; k.EntityId);
  
              modelBuilder.Entity&lt;EntityProperty&gt;().ToTable("EntityProperty");
              modelBuilder.Entity&lt;EntityProperty&gt;().HasKey(k =&gt; k.EntityId);
          }
      }
  </code></pre>
  
  <p>Problem when I use Include in query for get properties:</p>
  
  <p>Invalid column name 'SomeEntity_EntityId'.
  Invalid column name 'SomeEntity_EntityId'.</p>