SQLite and Entity Framework

2019-05-18 01:56发布

问题:

I'm trying to use SQLITE database with latest Entity Framework. I've installed SQLite provider x86 for .NET Framework 4.0 from here: http://system.data.sqlite.org/index.html/doc/trunk/www/downloads.wiki.

I succesfully added SQLITE as new data source by using server explorer in Visual Studio 2012. Then, I added new ADO.NET Entity Model and tried to add tables from my simple sqlite database. For some reason these tables can't be added and error log says following:

The data type 'longchar' is currently not supported for the target .NET Framework version; >>the column 'Name' in table 'main.Person' was excluded.

I dont understand why it's trying to convert SQLite TEXT type to longchar and fails. Can anyone help me with this problem?

回答1:

I was just getting this issue today after setting up my development environment for a project that uses SQLLITE and ADO at work and the fix was simple. Version 1.0.85.0 is broken and version 1.0.84.0 works.

32 BIT: http://system.data.sqlite.org/downloads/1.0.84.0/sqlite-netFx40-setup-bundle-x86-2010-1.0.84.0.exe

64 BIT: http://system.data.sqlite.org/downloads/1.0.84.0/sqlite-netFx40-setup-bundle-x86-2010-1.0.84.0.exe

Uninstall make sure to delete the program files for each install and also when you re-install tell the installer to rebuild your GAC. Should work that was the only difference between my and my boses build machine, that website needs to list previous revisions better.



回答2:

Alter your SQLite tables so that any TEXT fields are NVARCHAR(max) instead. .Net should map them correctly then.