Reputation: 3799
I am using EF5.x Code First
namespace DAO.Models
{
public partial class Person
{
public int UserId { get; set; }
}
}
i created another partial class to add custom properties.
namespace DAO.Models
{
public partial class Person
{
public string customName { get; set; }
}
}
I have a Mapping that has been generated for my by EF 5.x power tools
public PersonMap()
{
// Primary Key
this.HasKey(t => new { t.PersonId });
// Table & Column Mappings
this.ToTable("Person", "TableX");
this.Property(t => t.PersonId).HasColumnName("PersonId");
}
when i try to add a new person to db
XContext db = new XContext();
Person per= new Person();
db.Persons.Add(per);
I get unknown column customName in Field List error
Upvotes: 0
Views: 146
Reputation: 17680
You can use the [NotMapped] annotation/attribute
[NotMapped]
public string customName { get; set; }
Upvotes: 1