我得到一个可能很容易解决的常见错误,但我不知道如何解决。这是我得到的信息。
列名无效。[节点名称(如果有)= Extent1,列名称= Blog_BlogId]
说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息: System.Data.SqlServerCe.SqlCeException:列名无效。[节点名称(如果有)= Extent1,列名称= Blog_BlogId]
这是代表我的实体的类:
public class BlogContext : DbContext
{
public BlogContext()
: base("SqlCeServices")
{
}
public DbSet<User> Users { get; set; }
public DbSet<Blog> Blogs { get; set; }
public DbSet<Post> Posts { get; set; }
public DbSet<Category> Categories { get; set; }
public DbSet<Tag> Tags { get; set; }
}
[Table("aspnet_Users")]
public class User
{
[Required]
public Guid ApplicationId { get; set; }
[Required]
public Guid UserId { get; set; }
[Required]
public string UserName { get; set; }
[Required]
public string LoweredUserName { get; set; }
public string MobileAlias { get; set; }
[Required]
public bool IsAnonymous { get; set; }
[Required]
public DateTime LastActivityDate { get; set; }
}
public class Blog
{
[Key]
public int BlogId { get; set; }
[Required]
public string Name { get; set; }
public string Url { get; set; }
public int Rating { get; set; }
public virtual ICollection<User> Editors { get; set; }
public virtual ICollection<Post> Posts { get; set; }
}
public class Post
{
[Key]
public int PostId { get; set; }
[Required, MaxLength(200)]
public string Title { get; set; }
public string Content { get; set; }
public string Abstract { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateLastEdited { get; set; }
public virtual User UserId { get; set; }
public virtual ICollection<Category> Categories { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
public virtual Blog BlogId { get; set; }
}
public class Category
{
[Key]
public int CategoryId { get; set; }
[Required, MaxLength(200)]
public string Title { get; set; }
public string Description { get; set; }
public virtual ICollection<Post> Posts { get; set; }
public virtual Category ParentCategory { get; set; }
public virtual Blog BlogId { get; set; }
}
public class Tag
{
[Key]
public int TagId { get; set; }
[Required, MaxLength(200)]
public string Title { get; set; }
public virtual Blog BlogId { get; set; }
}