I'm using an Oracle 11g database with the ADO.NET Entity Data Model. Every now and then I run into this error and I have no idea what's causing it. I'm assuming it's something in the EDMX file or the designer file for it but I can't seem to figure it out. I've deleted the model, added it, updated, etc multiple times and can't figure out the issue. It works on other pages but this one seems to be a problem.
This has happened before, but simply removing and re-adding the table worked. Any ideas on how to fix this?
using (ODSData.Entities entities = new Entities())
{
var info = from item in entities.ODS_VALIDATIONRULE
select item;
newPK = Convert.ToInt32(info.Max(p => p.VALIDATIONRULEID)) + 1;
try
{
ODS_VALIDATIONRULE newRule = new ODS_VALIDATIONRULE();
newRule.ALLOWNULLIND = isNull;
newRule.CREATEDATE = DateTime.Now;
newRule.FAILIND = isFail;
newRule.MAXVALUEFACTOR = max;
newRule.MINVALUEFACTOR = min;
newRule.RULEDESCRIPTION = description;
newRule.SOURCESYSTEM = source;
newRule.TABLENAME = table;
newRule.COLUMNNAME = column;
newRule.DATATYPE = datatype;
newRule.VALIDVALUELIST = valid;
newRule.VALIDATIONRULEID = newPK;
entities.AddToODS_VALIDATIONRULE(newRule);
entities.SaveChanges();
insertAccepted = true;
}
catch
{
// Log Error
}
The error I'm getting is this: "An error occurred while preparing the command definition. See the inner exception for details."
Inner Exception: "Operation is not valid due to the current state of the object."