Entity Framework code is the first custom fieldd that I don't want to map to DB

I am using EF5. In my domain class, I have a field that I do not want to map to the table. But I have to make it publicly available so that other classes can access it:

public class Person { // these are mapped fields public string FirstName {get;set;} public string LastName {get;set;} // this is intended only for in-memory storage and not saved to DB public string LoginFromIP {get;set;} } 

The code above generates the "Invalid LoginFromIP column" error message when I try to save a new record because NOFlashFromIP is missing in my Person table.

When I delete the setter, it works. I think EF autofocus requires both getter and setter. How to save LoginFromIP property in a domain class only without creating a field in the DB table?

Thanks!

+6
source share
1 answer
 [NotMapped] public string LoginFromIP {get;set;} 
+8
source

Source: https://habr.com/ru/post/923412/


All Articles