Is it possible to work with Entity Framework (Code First) and have a data source that is an XML file? I need to populate domain objects with values ββfrom an XML file.
The XML file has the following structure:
<Person name="John" age="12"> <Products> <Product id="1" name="Product 1" /> <Product id="2" name="Product 2" /> <Product id="3" name="Product 3" /> </Products> </Person>
C # domain objects have the following structure:
public class Person { public string Name { get; set; } public int Age { get; set; } public ICollection<Product> Products { get; set; } } public class Product { public int Id { get; set; } public string Name { get; set; } }
I can use Linq for XML to parse each XML element and populate objects, but I was looking for a more automatic way to do this (if exists).
source share