I'm using Entity Framework 6 in my C# Project. When I have a Model class with let's say 20 properties but I only want to write 2 of these Properties in to my Database, is there a way to exclude all but say I want these 2 to be mapped. Small example here:
public class Blog
{
public int BlogId { get; set; }
[NotMapped]
public string Url { get; set; }
[NotMapped]
public DateTime LoadedFromDatabase { get; set; }
}
I want only my BlogId to be written into the Database, which means I would need to write [NotMapped]
for every other property in the class. Which also means when I add 10 properties, I need to write [NotMapped]
for every single property which can take some time.
Is there a way to make this easier, so for example something like "ignore all except specified properties"?