title: How to get the identity value in Entity Framework during SaveChanges?
body: <p>I've a base table and dependent tables, and other tables. EF 4.0 (using MS VS 2010 Ultimate) performs fine when a base table's identity value is mapped to dependent tables because of foreign key relationship. What I expect a bit more, is that, the same identity value should be mapped/copied to a column in unassociated/not related table which tracks key/value pair. For instance, if the base table's first record identity is generated as 1, I want this number to be copied into that key/value table. 
  When I tried, it's inserting as only 0 during SaveChanges() context in entity framework. This particular column is mapped to base table's column's identity property. It goes like,</p>
  
  <blockquote>
  <pre><code>BaseTable baseTable = new BaseTable();
  // Added properties of basetable values
  KeyValueTable table = new KeyValueTable();
  table.Key = baseTable.BaseId;
  table.Value = name;
  AddToKeyValueTable(table);
  SaveChanges();
  </code></pre>
  </blockquote>
  
  <p>If I take a look into KeyValueTable, this key is written as 0 instead of the baseTable's generated value. I suspect this problem would be that these tables are not associated with a relationship. I shouldn't do so as the key could hold other tables as well.</p>
  
  <p>Please assist me on this part.</p>
  
  <p>Thanks in advance!</p>