I have following Entity
[Table("classes")]
public class Class
{
public int classID { get; set; }
public Nullable<int> grade { get; set; }
public string classname { get; set; }
public Nullable<bool> Inactive { get; set; }
public Nullable<int> total { get; set; }
public virtual ICollection<Student> Students { get; set; }
public Class()
{}
}
This Entity is used at times by a stored procedure and at other times by entityframework (database first approach). Recently i added a field 'total' that is used by stored procedure. Now the entity framework gives error
'unknown column total in field list'
which is as expected.
My question is that is there a way i can set a default value in the onModelCreated function for total column so that it ignores the model change exception?
I am using EF6.
I think you can apply the [NotMapped]
attribute to total to tell EF that it's not in the database