【问题标题】:SQLite Xamarin Duplicate Column Id IssueSQLite Xamarin 重复列 ID 问题
【发布时间】:2016-12-09 04:50:07
【问题描述】:
var path = System.IO.Path.Combine (App.DEVICE_LOCAL_FOLDER, "database.db3");
            _database = new SQLiteAsyncConnection (path);
            _database.CreateTableAsync<Setting> ().Wait ();
            _database.CreateTableAsync<Authentication> ().Wait ();  

此代码在我的 Xamarin.Forms 应用程序的应用程序启动时执行,每次我的应用程序启动时,我都会收到“消息”重复列名称:setting_id“字符串”。我擦除了调试设备并从头开始启动只是为了确保没有创建重复的表或类似的东西。我的“设置”模型如下所示。

using SQLite;
namespace namespace
{
    public class Setting
    {
        [PrimaryKey, AutoIncrement]
        public int setting_id { get; set; }
        public string field1 { get; set; } =
            "";
        public string field2 { get; set; } = "";
        public string emailOne { get; set; } = "";
        public string emailTwo { get; set; } = "";
        public string field3 { get; set; } = "";
        public string field4 { get; set; } = "";
        public Setting ()
        {

        }
    }
}       

使用 Xamarin.Forms 版本 2.2.0.45 和 sqlite-net-pcl 版本 1.1.2。目前我只在 iOS 上测试过,它总是在应用启动时崩溃,还没有在 Android 上测试过。

【问题讨论】:

  • 你检查模拟器了吗?请参阅this forum post 了解可能的解决方案
  • @GeraldVersluis 我认为这可能是解决方案,我记得最近将“链接全部”设置为我的程序集设置。我会确认并回来。谢谢!

标签: android ios sqlite xamarin xamarin.forms


【解决方案1】:

感谢 Gerald Versluis,解决方案是确保我的程序集没有全部链接,一旦切换然后链接到“仅 SDK 程序集”,问题就解决了。

【讨论】:

    猜你喜欢
    • 2017-06-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-07
    • 2015-01-31
    • 2011-01-07
    • 1970-01-01
    • 2015-02-25
    相关资源
    最近更新 更多