C# sqlite entity framework - map string type
Clash Royale CLAN TAG#URR8PPP
C# sqlite entity framework - map string type
In SQLite in table I have column: Title and type of this column is string.
Now I want to map this table to Entity Framework in C#. And problem is with type string of that column because I cannot map it to string type in C#.
It works when I change in SQLite string to VARCHAR. But how to resolve this problem without changing column type?
1 Answer
1
Most SQL database engines (every SQL database engine other than
SQLite, as far as we know) uses static, rigid typing. With static
typing, the datatype of a value is determined by its container - the
particular column in which the value is stored.
SQLite uses a more general dynamic type system. In SQLite, the
datatype of a value is associated with the value itself, not with its
container. The dynamic type system of SQLite is backwards compatible
with the more common static type systems of other database engines in
the sense that SQL statements that work on statically typed databases
should work the same way in SQLite. However, the dynamic typing in
SQLite allows it to do things which are not possible in traditional
rigidly typed databases.
SqlLite Datatypes Reference
According to documentation the System.String
is mapped to TEXT
in SQLite so you cannot use string datatype for SQLite.
System.String
TEXT
TEXT: The value is a text string, stored using the database encoding (UTF-8, UTF-16BE or UTF-16LE).
Here is a table that's showing .Net SQLite default type mapping.
For more information please see
Entity Framework Data Types Mapping with .Net
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.