i m using EF Code First, and want to map an Entity class Person to entity table personTable as follows,
i have a an Entity Class
public class Person
{
public Guid Id
{
get;
set;
}
public string Email
{
get;
set;
}
public int Property
{
get;
set;
}
public Name Name
{
get;
set;
}
}
and a class for type of Property Name
public class Name
{
public string FirstName
{
get;
set;
}
public string FullName
{
get
{
return string.Format("{0} {1} {2}", FirstName, MiddleName, LastName);
}
}
public string LastName
{
get;
set;
}
public string MiddleName
{
get;
set;
}
}
i want to map person class to person table as follows
Person.Id => personTable.ID
Person.Name.FirstName ->personTable.FirstName
Person.Name.MiddleName => personTable.MiddleName
Person.Name.LastName => personTable.LastName
and so on....
where Person.Name is an object of type Name Class
Nameis a complex type and you must EF tell this, otherwise it will considerNameas an entity andPerson.Nameas a navigation property. Mapping with Fluent API: