Cannot refresh Entity. Record does not exist.

Discussion of open issues, suggestions and bugs regarding LinqConnect – Devart's LINQ to SQL compatible ORM
Post Reply
emp51302
Posts: 46
Joined: Fri 19 Aug 2011 20:57

Cannot refresh Entity. Record does not exist.

Post by emp51302 » Fri 24 Feb 2012 16:17

I am doing a simple insert in a table which is throwing the error "Cannot refresh Entity. Record does not exist." I have the latest version of dotConnect for MySQL and I am sick and tired figuring out what is going on!!!!

Below is my Code: Error throws on SubmitChanges. Please also see attached MySQL table schema.

Code: Select all

                    using (MyLinqDataContext dc = new MyLinqDataContext())
                    {

                        FeedUserEditor feedUserEditor = new FeedUserEditor
                        {

                            FeedId = FeedID,
                            UserId = UserID,
                            EditorLevelId = 1,
                            Timestamp = DateTime.Now,
                            IsActive = true

                        };


                        dc.FeedUserEditors.InsertOnSubmit(feedUserEditor);

                        dc.SubmitChanges(); //THIS IS THE PLACE IT THROWS ERROR!!!


                    }

Image



Please help me out with this issue ASAP. All other tablles work perfectly fine, but this newly created table with only few fields doesn't work. In this new table I have one field which is Primary Key and is set on AUTOINCREMENT.

EDIT: I checked the dbMonitor and this is what I see..

Execute: INSERT INTO mydb.feed_user_editor (feed_id, user_id, editor_level_id, `timestamp`, is_active) VALUES (:p1, :p2, :p3, :p4, :p5)

-- -1 row(s) affected.

The very next execution where the ERROR occurs and execution Rollback's after the above is,

Execute: SELECT editor_id FROM mydb.feed_user_editor WHERE editor_id = :key1 AND feed_id = :key2 AND user_id = :key3


Awaiting your response at the earliest.

Thank you!!!!!!!!!

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Post by MariiaI » Mon 27 Feb 2012 11:49

Please specify the version of dotConnect for MySQL you are using.
If it is a prior one, please try updating to the latest 6.70.311 build and tell us if this helps.
If the problem persists, please send us the model you are working with, so that we are able to analyze the situation in more details.

Zero-G.
Posts: 398
Joined: Sat 09 Dec 2006 12:20

Post by Zero-G. » Thu 29 Mar 2012 13:34

Hey

I am not a Devart guy, but maybe I can help you.

It seems, that the field
EditorLevelId
is specified as "Server generated value"
This means, that the server itself should generate the value, which you specify with the value "1"
When you save this, then the server code is executed, and inserted, not the "1" you give the DataContext.
And this seems to be the reason, why the Select is executed and there it doesn't find this entry. So the rollback is started and nothing seemed to be happenend

Hope this will help you in investigating your problem!
Have a nice day.

Post Reply