Note that there are some explanatory texts on larger screens.

plurals
  1. POUpdateException: Operation is not valid due to the current state of the object when using Entity Framework and Oracle
    primarykey
    data
    text
    <p>I'm attempting to add a new Entity object for persistence, however I'm getting an <a href="http://msdn.microsoft.com/en-us/library/system.data.updateexception.aspx" rel="nofollow">UpdateException</a> who's inner exception is an <a href="http://msdn.microsoft.com/en-us/library/system.invalidoperationexception.aspx" rel="nofollow">InvalidOperationException</a> with the message:</p> <blockquote> <p>Operation is not valid due to the current state of the object.</p> </blockquote> <p>Object being created:</p> <pre><code>var something = new SITE { EntityKey = new EntityKey("DataModelContainer.SITE", "SITE_ID", "ID"), SITE_COMMON_REFERENCE = "hello", SITE_ID = "hello" }; </code></pre> <p>which is then passed to:</p> <pre><code>public void ExportSiteData (SITE exportSiteData) { _context.SITE.AddObject(exportSiteData); _context.SaveChanges(); //&lt;-- Exception here } </code></pre> <p>The database is Oracle 11g and I can succesfully extract data via Entity Framework.</p> <p>I'm guessing the problem is more database side, however I can successfully populate it with both "hello" values with no key/referential integrity problems.</p> <p>I'd much appreciate being pointed in the right direction. Thanks</p> <p><strong>More code:</strong></p> <p>ExportSiteData is within <code>BillRepository</code> which implements <code>IDisposable</code>:</p> <pre><code>class BillRepository : IDisposable { private readonly DataModelContainer _context; public BillRepository() { _context = new DataModelContainer(); } public void ExportSiteData (SITE exportSiteData) { _context.SITE.AddObject(exportSiteData); _context.SaveChanges(); //&lt;-- Exception here } public void Dispose() { if (_context != null) { _context.Dispose(); } } } </code></pre> <p>and is called as such:</p> <pre><code>using (var repo = new BillRepository()) { repo.ExportSiteData(something); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload