how to get identity of an entity and set it as foreign key for another entity before savechanges?
===

i wanna add and an entity and get its identity before savechanges() and set it as a foreign key of another entity before savechanges in entity framework code first. is it possible?
 
first model

      public class A
    { 
       int AId { get; set; }
       string name { get; set; }
     }


second model

      public class B
    { 
       int BId { get; set; }
       int AId { get; set; }
       string name { get; set; }
     }

and.....
    
     db.As.Add(A);
     b.AId = A.Aid;
     db.savechanges();

is there any article which explains how it works?

