title: Invalid column name when inserting - Entity Framework
body: <p>I'm using Entity framework using code first. I have 3 tables in database:</p>
  
  <ul>
  <li>Place</li>
  <li>Profil</li>
  <li>PlaceMember</li>
  </ul>
  
  <p>It's a many to many relation. A place can have many Profils as members and a profil can be a member to many Places. The PlaceMember is the relational table.
  Code of PlaceDTO:</p>
  
  <pre><code>[Table("Place")]
  public partial class PlaceDTO
  {
      public PlaceDTO()
      {
          Members = new HashSet&lt;ProfilDTO&gt;();
      }
  
      public int id { get; set; }
  
      [StringLength(100)]
      public string description { get; set; }
  
      public DateTime dateOut { get; set; }
  
      public DateTime createDate { get; set; }
  
      public int? canceled { get; set; }
  
      public int profilId { get; set; }
  
      public int addressId { get; set; }
  
      public virtual AddressDTO Address { get; set; }
  
      public virtual ProfilDTO Profil { get; set; }
  
      public virtual ICollection&lt;ProfilDTO&gt; Members { get; set; }
  }
  </code></pre>
  
  <p>Code of Profil class:</p>
  
  <pre><code>public partial class ProfilDTO
  {
      public ProfilDTO()
      {
          Devices = new HashSet&lt;DeviceDTO&gt;();
          Notifications = new HashSet&lt;NotificationDTO&gt;();
          Places = new HashSet&lt;PlaceDTO&gt;();
      }
  
      public int id { get; set; }
  
      [Required]
      [StringLength(50)]
      public string pseudo { get; set; }
  
      [Required]
      [StringLength(50)]
      public string firstname { get; set; }
  
      [Required]
      [StringLength(50)]
      public string lastname { get; set; }
  
      [Required]
      [StringLength(15)]
      public string phone { get; set; }
  
      [Required]
      [StringLength(50)]
      public string emailAdresse { get; set; }
  
      [Required]
      [StringLength(150)]
      public string password { get; set; }
  
      public DateTime lastUpdatePassword { get; set; }
  
      public DateTime lastUpdateProfil { get; set; }
  
      public DateTime createDate { get; set; }
  
      public byte[] picture { get; set; }
  
  
      public virtual ICollection&lt;PlaceDTO&gt; Places { get; set; }
  }
  </code></pre>
  
  <p>Code of PlaceMember class:</p>
  
  <pre><code> [Table("PlaceMember")]
  public partial class PlaceMemberDTO
  {
      [Key]
      [Column(Order = 0)]
      [DatabaseGenerated(DatabaseGeneratedOption.None)]
      public int placeId { get; set; }
  
      [Key]
      [Column(Order = 1)]
      [DatabaseGenerated(DatabaseGeneratedOption.None)]
      public int invitedId { get; set; }
  }
  </code></pre>
  
  <p>In database, the <strong>placeId</strong> and <strong>invitedId</strong> are both identity key of the table.
  When I'm trying to add a new place to the Place table, I'm getting that PlaceDTO_id is not a valid column name despite the fact that the place table in database has an column named id and is the identity column.</p>
  
  <pre><code> context.Address.Attach(place.Address);
   context.Address.Add(place.Address);
  
   place.addressId = place.Address.id;
   context.Places.Attach(place);
   context.Places.Add(place);            
   context.SaveChanges();
  </code></pre>
  
  <p>The place object, put in param, contains 3 members that exists in Profil table.
  When I remove the <strong>Members</strong> field from the <strong>PlaceDTO</strong> table, the place is inserted but nothing added to the <strong>PlaceMember</strong> table.</p>
  
  <p>What's wrong ?</p>