I have the following class:
public class CompanyInfo
{
[Key]
public string CompanyId { get; set; }
public string CompanyName { get; set; }
public Address CompanyAddress { get; set; }
}
With the corresponding Address class:
public class Address
{
public string StreetAddress { get; set; }
public string StreetAddress2 { get; set; }
public string City { get; set; }
public string State { get; set; }
public string Zip { get; set; }
public string Plus4 { get; set; }
}
Here lies my problem ... the address now generates column names of type:
CompanyAddress_StreetAddress
where I would prefer something along the line of:
PrimaryStreetAddress
Given that the members of the Address class are not readily accessible for use with Data Annotation (using Domain Model/ViewModel structure) and are mapped in the controller as such:
var company = new CompanyInfo
{
CompanyId = GenerateAccountNumber(),
CompanyName = addCompany.CompanyName,
CompanyAddress = new Address
{
StreetAddress = addCompany.StreetAddress,
StreetAddress2 = addCompany.StreetAddress2,
City = addCompany.City,
State = addCompany.State,
Zip = addCompany.Zip,
Plus4 = addCompany.Plus4
},
-- some other fields here --
};
I know that the ViewModel is not the proper venue as it is just being mapped in the controller back to the model.
What would be the proper way to set the column names for the reusable class 'Address'? I'm assuming that this could be done through FluentAPI if Entity Framework but I am uncertain in how to proceed.
Any help would be greatly appreciated.