In my last post, we saw how to Serialize Object to XML and Deserialize XML to Object using a generic function, now we will see how to save
the deserialized object in a database using entity framework.
First I created a database called “WCF” with SQL Server 2012 Express, and created a table called Categories
Now with the same solution, I add another class project for my EntityFramework called “WcfServicesXmlSample.DO”, and add the table as a Entity
Now we need to create our ViewModel
In my interface I add my method
Our method inheritance from Interface
So as you can see, I’m using Automapper to mapping my Entity to my ViewModel, also I added a condition if the ID of the XML already exist,
just Update the data, otherwise, saved as a new record.