I have two classes called customer and address,customer is an entity while address is a value object.The definition of the classes are below:
public class Customer
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public Address ShippingAddress { get; set; }
public Address BillingAddress { get; set; }
}
[ComplexType]
public class Address
{
public string City { get; set; }
public string Street { get; set; }
public string StateOrProvince { get; set; }
public string Country { get; set; }
}
If I create a new customer and insert it into database using entity framework,the customer table has 11 columns,there are 8 columns for address property.How to config the entity framework so that the complex type "address" can be stored as a xml type(single column) in the customer table.
you may use https://servicestack.net/text . Although it does not serialize to XML, it's a good JSON serializer.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.