It's a Easter Monday, very quiet everywhere. I have been working with Sqlite and had an weird error. When I try to update a record in sqlite, using Entity Framework, it complains that the type of primary key id is system.int64.
My code is below
JobTable jobToUpdate = (from j in _entities.JobTableSet
where j.JobId == job.Id
jobToUpdate.Author = job.Author;
jobToUpdate.Customer = job.Customer;
jobToUpdate.Date = job.Date;
jobToUpdate.Description = job.Description;
jobToUpdate.Title = job.Title;
I struggled to sort it out for 30 minutes and gave up. I have a similar code in ASP.Net MVC 1 and it works ok.
30 minutes later.
For some reason, integer column in sqlite is Int64. When you use Entity Framework and create classes from database using the automated tool, it converts the column to Int32. So you have to change it to Int64 manually. Secondly, if you use your own model class, the type of the key needs to be long, not int, as int translates into Int32 (not sure what happens in 64bit windows)