Page 1 of 1
Sqlite autoincrement warning
Posted: Thu 21 Jun 2012 08:31
by dilbert
Entity Developer 4.4.197 now generates warning in .cs file (in VS 2010) for all SQLite primary keys with AUTOINCREMENT flag:
Code: Select all
Field 'DB.Users._Id' is never assigned to, and will always have its default value 0
Re: Sqlite autoincrement warning
Posted: Mon 25 Jun 2012 12:35
by MariiaI
This is the expected behaviour: since the entity key property has no setter, the corresponding field cannot be changed without using reflection.
We don't generate the code for a setter of properties that correspond to the autoincrement fields because there is no need in it (key is get from the database and assigned directly to the field, upon which the primary key property is built).
Re: Sqlite autoincrement warning
Posted: Tue 26 Jun 2012 09:29
by dilbert
Thank you for the comment. I agree that there is no need to generate a setter for autoincrement fields (at least in Sqlite).
However, generally, code that generates warnings could be confusing. Especially when there is a simple solution to generate setter with private access modifier or, even simpler, initialize its value in declaration (int _Id = 0).
I realize it isn't really a big issue and all real bugs should have higher priority. I'm just trying to keep my code without warnings...
Re: Sqlite autoincrement warning
Posted: Tue 26 Jun 2012 10:57
by MariiaI
Thank you for the suggestions. We will consider the possibility of disabling such warnings and inform you about the results.
Re: Sqlite autoincrement warning
Posted: Wed 27 Jun 2012 09:04
by MariiaI
The warning, related to the missing setter of properties, that correspond to the autoincrement fields, has been disabled. This update will be available in the next build of dotConnect for SQLite, which we plan to release in two weeks.