title: Foreign key id and description on SaveChanges() overide - Entity Framework
body: <p>I have a requirement to add a generic audit log for each entity, therefore I have overridden the <code>SaveChanges()</code> method in the <code>DbContext</code> class and able to create the logs. </p>
  
  <p>My issue is with the foreign keys, I need to get the text value of the foreign key instead of the id for the entities.</p>
  
  <p>Thanks in advance </p>
  
  <p>RJ</p>
  
  <p>here is the code</p>
  
  <pre><code>if (dbEntry.State == System.Data.EntityState.Modified)
  {
  if (!object.Equals(dbEntry.GetDatabaseValues().GetValue&lt;object&gt;(propertyName), dbEntry.CurrentValues.GetValue&lt;object&gt;(propertyName)))
  {
  var oldvalue = dbEntry.GetDatabaseValues().GetValue&lt;object&gt;(propertyName) != null ? dbEntry.GetDatabaseValues().GetValue&lt;object&gt;(propertyName).ToString() : "";
  var newvalue = dbEntry.CurrentValues.GetValue&lt;object&gt;(propertyName) != null ? dbEntry.CurrentValues.GetValue&lt;object&gt;(propertyName).ToString() : "";
  Auidlog += displayName + ": Changed from - " + oldvalue + " To - " + newvalue + " ";
  }
  }
  </code></pre>
  
  <p>in the oldvalue/newvalue  variable return only the foreign key id, I need the description for that</p>