Xamarin.Forms Sqlite-net NotSupportedException on ManyToOne relationship “Don't know about

后端 未结 1 1126
猫巷女王i
猫巷女王i 2021-01-23 14:05

I am using sqlite net extensions library in my xamarin.forms application. I code in my PCL the database code and models.

When I call SQLiteConnection.CreateTable() I get

1条回答
  •  孤独总比滥情好
    2021-01-23 14:33

    The problem was that I had installed two different libraries for sqlite, both containing a SQLiteConnection.

    I needed to use the Sqlite.Net.SQLiteConnection class for sqlite net extensions. Not the Sqlite.SQLiteConnection I was using.

    As SushiHangover pointed out, this Sqlite.Net.SQLiteConnection takes a first argument of type ISQLitePlatform.

    To obtain a reference for this, I defined an interface that provides the signature of a method to return a ISQLitePlatform:

    public interface ISQLitePlatformInstance
    {
        ISQLitePlatform GetSQLitePlatformInstance();
    }
    

    And I implemented the interface in my Droid project ( the platform I'm building against):

    public class SQLitePlatformInstance : ISQLitePlatformInstance
    {
    
        public ISQLitePlatform GetSQLitePlatformInstance()
        {
            return new SQLitePlatformAndroid();
        }
    
    }
    

    0 讨论(0)
提交回复
热议问题