views:

330

answers:

1

I'm tring to insert some records into my Sqlite database using the Entity Framework. I do not have a problem connecting to the database or mapping to the database. At least, I don't think I do. When I call "SaveChanges" an exception is fired that states:

Unable to update the EntitySet 'RawReadings' because it has a DefiningQuery and no element exists in the element to support the current operation.

Here is my code:

PyEntities p = new PyEntities();

System.Data.Objects.ObjectQuery<RawReading> readings = p.RawReadingSet;

RawReading rr = new RawReading();
rr.DateTime = new DateTime();
rr.Group = "353";
rr.Value = 555.33f;

p.AddObject("RawReadingSet", rr);
//EntityKey key = p.CreateEntityKey("RawReadingSet", rr);

try {
 p.SaveChanges(false);
}
catch (Exception ex) {
 MessageBox.Show(ex.InnerException.InnerException.Message);
}

What am I doing wrong? Has anyone else had this problem?

Thanks in advance.

A: 

It looks like the problem was caused because my Sqlite database did not have a primary key defined.

JP