Ich habe gerade versucht, ein umfangreiches Modell zu erstellen, zuerst mit dem POCO-Ansatz. Ich bekomme es aber nicht so, wie ich es wünsche. Lass uns einen Blog nehmen. Jeder Blog hat eine Reihe von Einträgen und jeder Eintrag hat eine Reihe von Kommentaren. Leider funktioniert das folgende Model nicht für mich. alt text http://blog.zoolutions.se/issue.pngEF4 - POCO Problem
Die Implementierung POCO-Klasse sieht wie folgt aus:
public class Blog
{
public bool Id { get; private set; }
public string Title { get; set; }
public bool AllowComments { get; set; }
public User User { get; set; }
public IList<Entry> Entries { get; set; }
}
public abstract class Post
{
public virtual int Id { get; set; }
public virtual string Header { get; set; }
public virtual string Text { get; set; }
public virtual DateTime CreatedAt { get; set; }
public virtual int UserId { get; set; }
}
public class Entry : Post
{
public Blog Blog { get; set; }
public IList<Comment> Comments { get; set; }
}
public class Comment : Post
{
public Entry Entry { get; set; }
}
Das bin ich eine sehr seltsame Fehler gibt:
System.Data.MetadataException: Schema specified is not valid. Errors: The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Entry'. Previously found CLR type 'Entry', newly found CLR type 'System.Collections.Generic.Dictionary
2+Entry'. The mapping of CLR type to EDM type is ambiguous because multiple CLR types match the EDM type 'Entry'. Previously found CLR type 'Entry', newly found CLR type 'System.Runtime.CompilerServices.ConditionalWeakTable
2+Entry'.
Irgendwelche Hinweise? Ich kann mich nicht um diese Fehlermeldung wickeln ...
Dank Alex, ich änderte es in BlogEntry, aber einige ich entdeckte, dass ich das Id-Feld von Blog zu bool als auch eingestellt hatte :) Ich lief in einige andere Probleme, aber sie sind einfacher zu arbeiten. – mhenrixon
Oh und mach weiter so Alex, ich liebe wirklich, dass du mit EF4 gehst! – mhenrixon