I'm 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 public 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 above code will generated a 'invalid column LoginFromIP' error message when I try to save a new record, because there is NO LoginFromIP in my Person table.
When I remove the setter it works. I guess EF's auto mapping requires both getter and setter. How do I keep my LoginFromIP property to the domain class only without create the field in DB table?
Thanks!