Hey all, posting here, though this may not necessarily be a Devart dotConnect specific issue. I really have no idea what is causing this and I was hoping someone could help.
I have two models that 'sort-of' look like this:
public abstract class Root
{
public Guid ID {get;set;}
}
public class User : Root
{}
public class SomeObject : Root
{
public virtual User Owner {get;set;}
}
If I add a user to my database, save changes, create 'SomeObject' set the Owner to the User that I added, then add my new 'SomeObject' instance to the database, I get the following when calling SaveChanges:
SQLiteException
"Abort due to constraint violation column ID is not unique."
Is this due to the fact that I have an ID for my SomeObject instance, then an ID for my User instance that the SomeObject entity is trying to keep track of? Shouldn't this be handled for me?
Anyway, any help would be greatly appreciated.
SQLite Constraint Violation
Re: SQLite Constraint Violation
Please turn on the dbMonitor tool in your application:
http://www.devart.com/dotconnect/sqlite ... nitor.html
http://www.devart.com/dbmonitor/dbmon3.exe
You will find out which DDL is generated for creating tables and corresponding DML statements with values of parameters - for inserting data. This should help to identify the reason of the problem. Notify us about the result.
http://www.devart.com/dotconnect/sqlite ... nitor.html
http://www.devart.com/dbmonitor/dbmon3.exe
You will find out which DDL is generated for creating tables and corresponding DML statements with values of parameters - for inserting data. This should help to identify the reason of the problem. Notify us about the result.
Re: SQLite Constraint Violation
That was great, thanks. It looks like EntityFramework was trying to re-add a virtual reference entity.
I added the following which seemed to solve the problem:
context.Entry(((SomeObject)item).Owner).State = EntityState.Unchanged;
Thanks again.
I added the following which seemed to solve the problem:
context.Entry(((SomeObject)item).Owner).State = EntityState.Unchanged;
Thanks again.