Sqlite extension is not working as expected

天涯浪子 提交于 2019-11-28 10:05:38

This is usually an installation issue caused because SQLite-Net Extensions was compiled using a SQLite-Net library but you are running your App using another. You can try adding the PCL NuGet package to your project or you can download the sources from Git and reference the project directly.

Try giving Table (Step) a Primary Key and a Foreign Key referencing Table (WorkFlow)

[Table("Step")]
public class Step
{
    [PrimaryKey, AutoIncrement]
    public int StepId { get; set; }
    [ForeignKey(typeof(WorkFlow))]
    public int WorkFlowId { get; set; }
    public string Type { get; set; }
    public string Description { get; set; }
    [ManyToOne]
    public Workflow Workflow { get; set; }
}

Fix: Uninstall all references to any SQLite NuGet packages from all projects, in my case this was a Xamarin.Forms solution. Clean the solution as an extra precaution (you could even check the packages are uninstalled from the packages folder just in case there's a file access issue blocking the delete). Install again by searching for SQLiteNetExtensions (not sqlite-net-pcl) and checking that the 'Include prerelease' option is selected in Visual Studio (tested on 2017). This will install sqlite-net-pcl v1.2.0 as the minimum dependency and several files including the word 'Raw'. You can test at this point to check the 'Don't know about System.Collections.Generic.List`1' error. For me, this disappeared. It should now be safe to update sqlite-net-pcl to the latest version, which at time of writing is v1.3.3.

Background: I encountered the same issue with the following combination:

  1. sqlite-net-pcl v1.3.3
  2. SQLiteNetExtensions v2.0.0-alpha2

In my first attempt I installed sqlite-net-pcl first through NuGet and then installed the latest stable version of SQLiteNetExtensions. After discovering the extensions are not compatible with sqlite-net-pcl I then updated to the latest pre-release version. I encountered the same 'Don't know about System.Collections.Generic.List`1' bug and found it very confusing leading me to try other things first and question if I'd made a mistake. Cleaning the project, deleting the packages (from the folder) and restoring did not work for me. I didn't check the packages config but using the NuGet manager and comparing to a test project everything was the same. Uninstalling everything as mentioned in my fix and letting SQLiteNetExtensions do the dependency checking for me fixed the problem. I think there was a problem buried in the NuGet files from having the wrong version of SQLiteNetExtensions initially.

P.S. Earlier in the day NuGet downloaded two packages for a fresh Xamarin.Forms project with 0KB file size that was installed in a typical way and I had to copy them in from another project. I don't normally get NuGet related issues.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!