C# 如何在';它与数据库无关吗?

C# 如何在';它与数据库无关吗?,c#,entity-framework,asp.net-mvc-4,C#,Entity Framework,Asp.net Mvc 4,我有一个模型课: [Table("items")] public class items { public int id { get; set; } public string text { get; set; } public string value { get; set; } // public int test { get; set; } crashes } 我使用实体框架。我的表有id、text、value和test属性不在其

我有一个模型课:

[Table("items")]
public class items
{
        public int id { get; set; }
        public string text { get; set; }
        public string value { get; set; }
   //   public int test { get; set; } crashes
}
我使用实体框架。我的表有
id、text、value
test
属性不在其中。我这样填充我的
DbSet

公共数据库集项{get;set;}

奇怪的是,如果我添加类似于
公共列表测试{get;set;}
的内容,它不会崩溃

我该怎么办?我最初想添加一个
bool?
属性

编辑:
我正在考虑创建一个新类来继承模型,但我必须重新映射/重新填充它。

您可以添加
NotMapped
属性

例如:

[Table("items")]
public class items
{
    public int id { get; set; }
    public string text { get; set; }
    public string value { get; set; }

    [NotMapped]
    public int test { get; set; }
}

items
是与数据库关联的数据模型。如果希望在视图中使用其他不相关的属性,则应使用视图模型。请使用[Ignore]数据注释OHHHHHHHHH我看到了。让我试试。这个解决方案有什么缺点吗?