Chlodny series Day 2: Reverse Engineer Existing Database

To continue on with the series of creating an application that utilizes ASP.NET Web API. This demo application utilizes the Chinook database.  In order to use Entity Framework code first with the lease amount of hassle the application will use a reverse engineering tool created by the EF team and included in the Entity Framework Power Tools.

After the extension is installed and Visual Studio has been restarted it is time to create a new project to hold the Code First models and contexts.

  • Right click on the ChlodnyWebApi solution
  • Go to Add
  • Select New Project
  • Under Visual C# –> Windows –> select Class Library
  • Name the Project DataAccess
  • Click OK

After the project is created the default class file can be deleted.  Now to reverse engineer the database.

  • Right click on DataAccess
  • Under Entity Framework select Reverse Engineer Code Frist

(if you do not see this, see above to install the extension)

CropperCapture[43]

  • Setup the connection properties to connect to the Chinook database
  • Test the connection to verify you can connect
  • Click Ok

CropperCapture[56]

After the magic happens there will be a two new folders and a context created.  The entities folder are the domain classes and the mappings folder is the configuration files that tells Entity Framework how the tables are configured using the fluent API.

CropperCapture[57]

Advertisements
This entry was posted in Entity Framework, MVC, Web and tagged , , , , . Bookmark the permalink.

One Response to Chlodny series Day 2: Reverse Engineer Existing Database

  1. Pingback: Released Entity Framework Power Tools Beta 2 | Research ~ A ~ holic

Comments are closed.