Long time listener, first time caller…
So I’m converting an existing app over to ef. I am enjoying the experience so far. I have a POCO class that has some simple user properties.
ex.
public string FirstName { get; set; }
public string LastName { get; set; }
other properties...
public string FullName
{
get { return FirstName + " " + LastName; }
}
How do I accomplish this with EF? Can is be done in the EDM, or do I have to create a partial class? I prefer the EDM…
You need partial class because this is property computed in your code not in database. Problem here is that read/write entity must have only properties mapped to a table but your table probably doesn’t have
FullNamecolumn = you can’t map it and you can’t use it in queries. Computed properties in EDM are possible but only if you have read only entity defined by Query view (view defined in ESQL) or Defining query (custom SQL select). If you want to useFullNamein query you must define it as model defined function. Query view, Defining Query and model defined functions are advanced EF features which are not available in designer. You must open EDMX as XML and edit it manually.