2017-07-25 8 views
0

Sie können den Fehler in Titel anzeigen. Es gibt meine Tabellenklassen:SQLite Extensions-Ausnahme: ManyToOne-Beziehungsziel muss Primärschlüssel haben

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() 
    { 
    } 
} 

Fehler tritt hier:

inst.GetChild(car, "Model"); 

inst ist SQLite.Net.SQLiteConnection Instanz

Alles funktionierte gut, wenn ich Bibliothek als einfacher Code verwendet, aber jetzt habe ich es als PCL-Referenz. Wie Sie sehen können, existiert PrimaryKey in Models Tabelle. Was ist mit diesem Code falsch?

Antwort

Verwandte Themen