I have a POCO class
public class Main
{
public int ExstraColumn{ get; set; }
}
public class User : Main
{
[Key]
public int Id { get; set; }
public int? Age { get; set; }
}
public class News : Main
{
[Key]
public int Id { get; set; }
public int? ReadCount { get; set; }
}
now i want entity framework inserts only age column in user. But it gives invalid column name ExstraColumn
how to tell entity framework that ExstraColumn field is only special usage?
You can use the [NotMapped]
attribute in the System.ComponentModel.DataAnnotations namespace.
Denotes that a property or class should be excluded from database mapping.