Do you allow the entity framework to create your database, or do you do it yourself?
You need text affinity on the columns in question. Then any numbers will be stored as text, not numbers. See: https://sqlite.org/datatype3.html Particularly: 3.1. Determination Of Column Affinity The affinity of a column is determined by the declared type of the column, according to the following rules in the order shown: 1) If the declared type contains the string "INT" then it is assigned INTEGER affinity. 2) If the declared type of the column contains any of the strings "CHAR", "CLOB", or "TEXT" then that column has TEXT affinity. On 21 December 2017 at 23:06, Алексей Люльченко <lulchenkoalek...@gmail.com> wrote: > Dear Sir! > > I would like to ask you to help me with an issue which appears while I use > System.Data.SQLite database engine. > > I use .net framework 4.0.0, EntityFramework 6.2.0 and SQLite 1.0.106. I > have an entity with properties of string type. This entity is mapped > to my database table which has the same structure (columns names and data > types). When I write and read back data to and from the database, all is OK > while these columns have strings like "abcdef" or "123abc". But when I try > to write a string like "1234" it is written to the database table like an > int data type value. I know that it is a normal behavior and it is not an > issue (https://sqlite.org/faq.html#q3). But I get the > "System.InvalidCastException" when I try to read back the row from the > database to my entity because the datatypes are different (the entity has > the property of string type but the database table now has the cell of int > datatype). > > Please, give me the clues what is going wrong, if you can. I think it is a > typical bug in many situations. > > Thank you in advance! > > Yours Faithfully, > > Aleksey Lulchenko, .Net developer at "TDabbat". > Saratov, Russia > _______________________________________________ > sqlite-users mailing list > sqlite-users@mailinglists.sqlite.org > http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users