将BlogTypes注释掉,但因为Blogs中定义了BlogType 这样类型的属性,所以Ef会聪明的找到BlogType类.

 public class BlogEntities:DbContext
{
static BlogEntities()
{
Database.SetInitializer(new DropCreateDatabaseIfModelChanges<BlogEntities>()); } public DbSet<Blog> Blogs
{
get;
set;
} //public DbSet<BlogType> BlogTypes
//{
// get;
// set;
//} public DbSet<TestUser> TestUsers
{
get;
set;
}
}

Blog类

public class Blog
{
public int BlogId
{
get;
set;
} public string Title
{
get;
set;
} public DateTime CreateTime
{
get;
set;
} public int BlogTypeId
{
get;
set;
} public BlogType BlogType
{
get;
set;
}
}
05-11 14:44