重复的列名在SQLite为Windows Phone

本文关键字:SQLite Windows Phone | 更新日期: 2023-09-27 18:12:38

我正在尝试使用SQLite为Windows Phone创建一个表:

[Table("Accounts")]
public class Account : ObservableObject
{
    private int id;
    private string name;
    private double balance;
    [Column("id"), PrimaryKey, AutoIncrement]
    public int ID
    {
        get { return this.id; }
        set { Set(() => ID, ref id, value); }
    }
    [Column("name")]
    public string Name
    {
        get { return this.name; }
        set { Set(() => Name, ref name, value); }
    }
    [Column("balance")]
    public double Balance
    {
        get { return this.balance; }
        set { Set(() => Balance, ref balance, value); }
    }
}
Connection = new SQLiteAsyncConnection("database.sqlite");
await Connection.CreateTableAsync<Account>();

CreateTableAsync方法引发SQLiteException并返回一条消息"duplicate column name: id"。怎么了?

重复的列名在SQLite为Windows Phone

使用[Ignore]属性对于不打算作为表列的属性