LINQ and C #: how to add a field and not mapped to a table column

I am loading records from a database table. I need to add a field called "temp" that doesn't match any columns in the table. How do 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
    }
}

      

Thank you and welcome.

+3


source to share


1 answer


Use the attribute [NotMapped]

.

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

      



Any property or class that has an attribute NotMapped

will be excluded from the database mapping.

+7


source







All Articles