Visual Studio 2012 database modeling

 

Adding Database Model to Visual Studio 2012

by Lawrence Patrick Me_2012_2

I have always used ER/Studio for my data modeling projects, However the license can be expensive.  One great feature that ships with Visual Studio is the ADO.NET Entity Data Model tools.  This functionality easily allows you to reverse engineer a SQL database and visualize your tables.  I do not recommend Visio for this type of work because it uses ODBC.  I did try using Visio 2013, only to learn that Microsoft is pushing this functionality out to Visual Studio.  I love Visio for all types of diagrams like web drawings delivered via SharePoint – but not for reverse or forward engineering data models. 

Let’s see how easy it is to do this using Visual Studio 2012

 

Open up your solution, in my case I am working on a Class to run Machine learning algorithms on data.  Your solution may look different but the process is still the same. 

 

if you are reverse engineering a data model then Step one is to add a connection to your SQL Server that contains the data you will use for the data model.  If you plan to forward engineer a model then you can skip this step .

 

Step 1: Add Database connection to solution
Go to Tools > Connect to Database
image

 

Fill in your details and click OK, the connection is now a part of your solution.  Now move to step two.

image

 

Step 2: Add the model canvas to the solution,

Right Click on your project – Select New Item and on the “Add New Item” Dialog opens up click on Data on the left and select ADO.NET Entity Data Model.  Give your model a name and click Add.

 

image

 

image

Now select Add> and now if you are forward engineering a data model, that is if the model does not exist yet and you are going to create it in Visual Studio and push the model out to a database – you would select Empty Model.

 

If you are reverse engineering an existing database with tables then select
”Generate from Database”   You will use the connection you setup in step 1.
image

 

 

Step 3: Use the Entity Data Model Wizard. – Select your connection or create a new one and click Next.

image

Select your objects and options and click Next.  Then click Finish.

image

image

Finished!  Your model should show up just fine or with a few primary key warnings.    Hope this helps.

Leave a Reply