MS SQL – C# – Entity Framework Project (import Data from XML, export to PDF)

In this project you’ll see how to use Entity Framework with MS SQL, parse data from XML file and export PDF with data from a database.

The project is about “Music store” where you have XML file with data about music albums. You should parse the date and fill it into database. Then you can make queries and get the results in PDF all done by C#.

The source files

If you try to start the project you’ll need Visual Studio and MS SQL Server.
Don’t forget to change the connection string in all App.config files (If you are using SQL Server Express, change the ‘.’ in “source=.”, with ‘.\SQLEXPRESS’).

I’ve created a simple database (use the music_store_db.sql script to generate the tables) and using Entity Framework (db first), C#, XPath and ItextSharp I’m parsing data from .xml file and I’m filling the data into db tables, then I’m exporting some data into .pdf.

The XMLParser.cs parse the date from XML and calls the Method “AddAlbumToDB” (MusicStoreDAL.cs) which fills the database tables with the parsed data.
The PDFExporter.cs makes a query to the database, makes PDF file and fills the data into it.
The Executor.cs calls XMLParser and PDFExporter (for ease).

The Pdf

SQL Diagram