Last post Oct 16, 2018 04:56 PM by DA924
Oct 16, 2018 04:40 PM|Irakli_Lomidze|LINK
What is the best way to Serialize/Deserialize EF Dbcontext or its part to XML file.
Like it was in ADO.NET DataSet. You had possibility to read and write data with it's schema.
Does this have analog in EF ?
Thank you in Advance.
Oct 16, 2018 04:52 PM|PatriceSc|LINK
It wouldn't really make sense for a DbContext (which uses an underlying connection).
Usually you are serializing a graph of entities. The general documentation is https://docs.microsoft.com/en-us/dotnet/standard/serialization/introducing-xml-serialization but
you may want to give the big picture so that we can better understand what is your real goal and see if you could have a better option.
For example when creating/consuming web APIs serialization/deserialization can be done for you. If this is to persist data it would be best to just use a "true" database.
Oct 16, 2018 04:56 PM|DA924|LINK
Serialize Dbcontext for what purpose to send it somewhere like a Dataset? No, Dbcontext should not be sent any where the objects on the virtual model object accessable by the Dbcontext can be serialized and sent somewhere. Better yet, a POCO or a DTO is
serialized and sent somewhere. The Dbcontext has no, nada and none behaviors or characteristics of an ADO.NET dataset.