A developer's braindump

Entity Framework - export your context as xml

Ever wanted to export your context as XML and get a representation of what is contained in it's local view or with all linked properties even if not already loaded in your context.

  • create an entity
  • add it to the context
  • get it's xml representation.
Author cedric = new Author() { 
                    FirstName = "Cedric", 
                    LastName = "Dumont" 

string s = await appContext.AsXmlAsync();
  • will result in :
  • to do this, you will need this

PM> Install-Package CExtensions.EntityFramework -Pre

Next: /2015/08/29/entity-framework-get-the-mapping-between-table-entity-properties-and-columns-at-runtime-ef-6-1/
Prev: /2015/08/15/entityframework-in-memory-testing-with-xml-files/