<?xml version="1.0" encoding="utf-8" ?>
<?xml-stylesheet type="text/xsl" href="RSS_xslt_style.asp" version="1.0" ?>
<rss version="2.0" xmlns:WebWizForums="http://syndication.webwiz.co.uk/rss_namespace/">
 <channel>
  <title>DevForce Community Forum : SaveChanges and EntityManagerSaveException</title>
  <link>http://www.ideablade.com/forum/</link>
  <description>This is an XML content feed of; DevForce Community Forum : DevForce 2009 : SaveChanges and EntityManagerSaveException</description>
  <pubDate>Sat, 11 Apr 2026 10:40:29 -700</pubDate>
  <lastBuildDate>Tue, 09 Dec 2008 18:52:08 -700</lastBuildDate>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Web Wiz Forums 9.69</generator>
  <ttl>360</ttl>
  <WebWizForums:feedURL>www.ideablade.com/forum/RSS_post_feed.asp?TID=1015</WebWizForums:feedURL>
  <image>
   <title>DevForce Community Forum</title>
   <url>http://www.ideablade.com/forum/forum_images/IdeaBlade_logo_tm.png</url>
   <link>http://www.ideablade.com/forum/</link>
  </image>
  <item>
   <title>SaveChanges and EntityManagerSaveException : FYI to anyone else having this...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1015&amp;PID=3698#3698</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=11" rel="nofollow">kimj</a><br /><strong>Subject:</strong> 1015<br /><strong>Posted:</strong> 09-Dec-2008 at 6:52pm<br /><br />FYI to anyone else having this problem - the error is caused by a DevForce bug which should be fixed in the Jan/Feb 2009 release.&nbsp; The workaround until then is to ensure that you remove all Unchanged entities from the cache of the EntityManager used by your IEntityServerSaving implementation before exiting the handler.]]>
   </description>
   <pubDate>Tue, 09 Dec 2008 18:52:08 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1015&amp;PID=3698#3698</guid>
  </item> 
  <item>
   <title>SaveChanges and EntityManagerSaveException : I created a Audit Trail feature...</title>
   <link>http://www.ideablade.com/forum/forum_posts.asp?TID=1015&amp;PID=3686#3686</link>
   <description>
    <![CDATA[<strong>Author:</strong> <a href="http://www.ideablade.com/forum/member_profile.asp?PF=399" rel="nofollow">LesleySastro</a><br /><strong>Subject:</strong> 1015<br /><strong>Posted:</strong> 05-Dec-2008 at 12:44pm<br /><br />&nbsp;I created a Audit Trail feature by using an implementation of IEntityServerSaving. Basically what I do, is checking for each entity to be saved what action (insert, update or delete) has taken place and what data properties has changed. The action together with the user and a timestamp I store in an AuditDataAction table and the changed properties with their original and new values in an AuditDataFields table (so we have a master-detail relationship). In the IEntityServerSaving class I'm creating and adding the AuditDataAction and AuditDataField entities to the passed in EntityManager for saving. And here is where I get confused. I'm getting the following exception<DIV>&nbsp;</DIV><DIV>Object reference not set to an instance of an object.</DIV><DIV>&nbsp;</DIV><DIV>When debugging and looking at the SaveResult, I'm seeing Cancelled=False, FailureType=Other, and for EntitiesWithErrors I get one entity of type User. This is not the original entity I was saving, and for that matter looking at the EntityState of that User entity I see the state Unchanged, and no errors. This User entity is only used to fill in the user link for the AuditDataAction entity. I am also using the EntityManager.FindEntities(EntityState.Added | EntityState.Modified | EntityState.Deleted) method to find all the entities that needs to be saved, and the User entity is for sure not one of them.</DIV><DIV>&nbsp;</DIV><DIV>When turning the Audit Trail feature off, I'm not getting any exceptions and the entities are saved correctly into the database. So it should be something that I have done within the IEntityServerSaving class, like adding the audit entities. But I'm not getting anywhere with the error message exposed. Does anyone have any idea how I can better determine the cause of the failure?</DIV><DIV><FONT color=#2b91af size=2>&nbsp;</DIV></FONT>]]>
   </description>
   <pubDate>Fri, 05 Dec 2008 12:44:06 -700</pubDate>
   <guid isPermaLink="true">http://www.ideablade.com/forum/forum_posts.asp?TID=1015&amp;PID=3686#3686</guid>
  </item> 
 </channel>
</rss>