1

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."

2
  • 1
    Could this be related to the Security patch released by MS on 12/29/2011? Aforementioned update. Commented Jan 15, 2013 at 21:45
  • Just tried the fix there, still getting the same error. Commented Jan 15, 2013 at 21:58

2 Answers 2

1

Apparently the issue here was somewhere in the EDMX file and the way it read from Oracle. I deleted the table and recreated it in the DB as well as the EDMX and then added it back. It worked fine then.

Sign up to request clarification or add additional context in comments.

Comments

0

The only thing I see that seems odd is you aren't using a sequence for your Pk value. You may try creating one and see if that helps at all.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.