I load records from a database table. I need to add a field called "temp", which does not correspond to any table column. How can I add this field?
namespace mynamespace.Models
{
public class alert
{
[Key]
public int id { get; set; }
public string text { get; set; }
public string temp { get; set; } //<--- this generates error
}
}
Thanks and regards.
Use the [NotMapped]
attribute.
[NotMapped]
public string temp { get; set; }
Any property or class that has the NotMapped
attribute will be excluded from database mapping.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With