2017-07-25 4 views
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参照。ご覧のとおり、PrimaryKeyはModelsテーブルに存在します。このコードで何が問題になっていますか?

答えて

関連する問題