Entity framework 实体框架代码我没有的第一个自定义字段';我不想映射到数据库

Entity framework 实体框架代码我没有的第一个自定义字段';我不想映射到数据库,entity-framework,code-first,Entity Framework,Code First,我用的是EF5。在我的域类中,我有一个不想映射到表的字段。但我必须将其公开,以便其他类可以访问它: public class Person { // these are mapped fields public string FirstName {get;set;} public string LastName {get;set;} // this is intended only for in-memory storage and not saved to DB

我用的是EF5。在我的域类中,我有一个不想映射到表的字段。但我必须将其公开,以便其他类可以访问它:

public class Person
{
   // these are mapped fields
   public string FirstName {get;set;}
   public string LastName  {get;set;}

   // this is intended only for in-memory storage and not saved to DB
   public string LoginFromIP {get;set;}
}
当我尝试保存新记录时,上面的代码将生成“invalid column LoginFromIP”错误消息,因为我的Person表中没有LoginFromIP

当我移除setter时,它会工作。我想EF的自动映射需要getter和setter。如何在不在DB表中创建字段的情况下仅将LoginFromIP属性保留到域类

谢谢

[NotMapped]
public string LoginFromIP {get;set;}