robertohuertasm / SQLite4Unity3d

SQLite made easy for Unity3d
MIT License
1.27k stars 265 forks source link

NotSupportedException: Cannot update List`1: it has no PK #126

Open StevenDextrain opened 11 months ago

StevenDextrain commented 11 months ago

Hello guys, I need your help, I'm using SQLite4Unity3d on Unity, and I have this error : NotSupportedException: Cannot update List`1: it has no PK The line giving this error is :

var updateQuery = DatabaseManager.database.Query<Device>("UPDATE Device SET lastCalibration = ? WHERE Id = ?", DateTime.Now, currentDevice.Id);
DatabaseManager.database.Update(updateQuery);

currentDevice.Id is a simple int, in this instance, it's 1. For some reason, the update works (updates my DB correctly), but causes issues with my application so I can't keep it like that. I've already checked multiple times, the table HAS a primary key (Id), it is correctly initialized in my class, and I don't know where this issue could come from. I've looked around the internet and didn't find a solution that worked for me, so I'm contacting you as a last resort. Thanks in advance for your answers, let me know if you need more information, have a great day !