所以我就麻煩了這個錯誤:類型的未處理的異常「System.Data.Entity的...... ModelValidationException」發生在EntityFramework.dll
An unhandled exception of type 'System.Data.Entity.ModelConfiguration.ModelValidationException' occurred in EntityFramework.dll.
private void button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show("Are you sure?");
var db = new AndmebaasContext();
Console.WriteLine("vajtuasid comboboxi");
string name = "Peeter";
int number = 5081976;
long isikukood = 39502266016;
bool Kliendikaart = true;
//DateTime TulebJargi = new DateTime(02, 01, 2015);
// DateTime ToobTagasi = new DateTime(23, 01, 2015);
string lumelauad = "Flow 150";
string MaeSuusad = "Rossignol 170";
var kliendinimi = new Kliendid { KliendiNimi = name};
db.Kontakt.Add(kliendinimi);// ERROR Seems to be HERE!!!
db.SaveChanges();
var query = from b in db.Kontakt
orderby b.KliendiNimi
select b;
foreach (var item in query)
{
Console.WriteLine(item.KliendiNimi);
}
因此,這是一部分wpf中的一個主要腳本,我在visual studio編譯器爲我顯示錯誤的地方寫了一條評論。
public class AndmebaasContext : DbContext
{
public DbSet<Kliendid> Kontakt { get; set; }
public DbSet<KliendiRendiAndmed> KliendiRendiAndmed { get; set; }
public DbSet<KliendiRenditudVarustus> KliendiRenditudVarustus { get; set; }
}
,哪些是用來做數據庫和最後一堂課propably有一個錯誤
public class Kliendid
{
public int KliendiID { get; set; }
public string KliendiNimi { get; set; }
public int KliendiNumber { get; set; }
public long KliendiIsikukood { get; set; }
public bool KliendiKliendikaart { get; set; }
public virtual List<KliendiRendiAndmed> Kliendirendiandmed { get; set; }
}
public class KliendiRendiAndmed
{
public int KliendiRendiAndmeteID { get; set; }
public DateTime TulebJärgi { get; set; }
public DateTime ToobTagasi { get; set; }
public virtual List<KliendiRenditudVarustus> Kliendirenditudvarustus {get; set;}
}
public class KliendiRenditudVarustus
{
public int KliendiRenditudVarustuseID { get; set; }
public string LumeLaud { get; set; }
public string LumeLauaSaapad { get; set; }
public string MaeSuusk { get; set; }
public string MaeSuusaSaapad { get; set; }
public string SuusaKepid { get; set; }
public virtual Kliendid Kliendid { get; set; }
}
希望有人可以幫助我這樣的歡呼和新年快樂! :)