當我嘗試創建自己的POCO類時,出現此錯誤。這隻有當我得到一個類似或acsosiation列表,在這種情況下,作者得到了書籍。但是,當我使用T4時,它很好用。我還挺喜歡創建自己的班,因爲這樣我可以我AddBook()添加到它..所以我非常感激,如果有人知道爲什麼..創建自己的POCO類不會奏效。錯誤指定的架構無效
Schema specified is not valid. Errors:
The relationship 'EworkModel.AuthorBook' was not loaded because the type 'EworkModel.Book' is not available.
The following information may be useful in resolving the previous error:
The required property 'AuthorId' does not exist on the type 'EntityWork.Model.Book'.
我的課是這樣
public class Author
{
public virtual int AuthorId { get; set; }
public virtual string Name { get; set; }
public List<Book> Books { get; set; }
}
public class Book
{
public virtual int BookId { get; set; }
public virtual string Title { get; set; }
public virtual Author Author { get; set; }
}
private ObjectSet<Author> _authors;
private ObjectSet<Book> _books;
public EntityWorkContext()
: base("name=EworkEntities", "EworkEntities")
{
_authors = CreateObjectSet<Author>();
_books = CreateObjectSet<Book>();
ContextOptions.LazyLoadingEnabled = true;
}
public ObjectSet<Author> Authors
{
get
{
return _authors;
}
}
public ObjectSet<Book> Books
{
get
{
return _books;
}
}
public void Save()
{
SaveChanges();
}
只是要拋出這裏,但我只使用虛擬與其他實體類型,而不是基本類型,如「int」。我不能說這是否是問題的一部分。 – Buildstarted 2010-10-04 02:43:29