0
您可以在標題中看到錯誤。 有我的表類:發生SQLite擴展異常:ManyToOne關係目標必須具有主鍵
public class Cars : Table
{
[NotNull]
public string name { get; set; }
[ForeignKey(typeof(Models)), NotNull]
public int model_out_id { get; set; }
[ForeignKey(typeof(Bodies)), NotNull]
public int body_out_id { get; set; }
[MaxLength(50)]
public string vin { get; set; }
[MaxLength(4), NotNull]
public int year { get; set; }
[Indexed, NotNull]
public long created_at { get; set; } = DateTime.Now.GetTimestamp();
[ManyToOne(CascadeOperations = CascadeOperation.CascadeRead)]
public Models Model { get; set; }
[ManyToOne(CascadeOperations = CascadeOperation.CascadeRead)]
public Bodies Body { get; set; }
[OneToMany]
public List<CarGlasses> CarGlasses { get; set; }
public Cars()
{
}
}
public class Models : TableLibrary
{
[PrimaryKey, NotNull]
public int out_id { get; set; }
[NotNull]
public string name { get; set; }
[ForeignKey(typeof(Marks)), NotNull]
public int mark_out_id { get; set; }
[Indexed, NotNull]
public int year_from { get; set; }
[Indexed]
public int? year_to { get; set; }
[ManyToOne(CascadeOperations = CascadeOperation.CascadeRead), Ignore]
public Marks Mark { get; set; }
public Models()
{
}
}
錯誤的位置:
inst.GetChild(car, "Model");
inst
是SQLite.Net.SQLiteConnection
例如,當我用庫作爲明碼
一切工作正常,但現在我增加一條,作爲PCL參考。正如您可以看到在Models
表中存在PrimaryKey。這段代碼有什麼問題?