How to view database diagram in a Code First using localdb

32,196

Solution 1

Install Entity Framework Power Tools Beta 4, restart Visual Studio, right-click on the context in your solution view and you'll see a new 'Entity Framework' option in the context menu. Select 'View Entity Data Model' to see a beautiful visual database diagram in Visual Studio. Voilà!

Entity Framework 6 Power Tools: Link

Solution 2

You can use Microsoft SQL Server Management Studio 2012 with localdb which supports Database Diagrams in they way you may be used to with other SQL Server database.

  1. Open Management Studio (should have been installed with Visual Studio)
  2. Connect to (localdb)\v11.0, with Windows Authentication
  3. Find the relevant database
  4. Expand Database Digrams, and install diagram support objects if you've not already
  5. Add the tables you need and you're done!

Source: This older but still relevant article: http://visualstudiomagazine.com/blogs/data-driver/2012/05/visual-studio-11-beta-easier-development-localdb.aspx

Solution 3

I checked out the Entity Framework Power Tools Beta 4 and it is no longer being supported. Intead, you can use the new Entity Framework 6 Power Tools Community Edition.

It is supposed to work the same.

Share:
32,196
Xaqron
Author by

Xaqron

Physician

Updated on October 01, 2020

Comments

  • Xaqron
    Xaqron over 3 years

    I have a Code First project with Entity Framework 5.0.0 using localdb created in Visual Studio 2012 Ultimate. Although I can see my class relations in a Class Diagram, how to see a visual diagram of automatic generated database by EF ?

  • Ralph Lavelle
    Ralph Lavelle over 11 years
    Yeah, very handy in certain circumstances. You can also reverse-engineer an existing db into a bunch of classes, which can save a lot of time if working EF into an existing db situation.
  • Xaqron
    Xaqron about 11 years
    Good for now. It should support changes via model (currently it is read-only)
  • TimS
    TimS over 10 years
    I do use this and it's handy. However, this isn't strictly a diagram of the SQL database though, it's an EF model of it. The penny dropped and I found you can use SQL Server Management Studio 2012 to do this using the usual Database Diagram tool. See my answer below.
  • Cristian Diaconescu
    Cristian Diaconescu over 8 years
    This doesn't work out of the box for VS 2015. Here's Julie Lerman on how to make it work: thedatafarm.com/data-access/…
  • Mike Devenney
    Mike Devenney about 8 years
    or, just download Julie's .visx from here if you're in a rush.
  • RBT
    RBT almost 8 years
    +1. Very nice. Without this I was unable to verify if the foreign key relationships were getting created or not. Thanks!
  • Tian van Heerden
    Tian van Heerden almost 6 years
    For those coming later e.g. using the default template for a Code First app with LocalDB, just use the server instance part of your connection string to connect SSMS to - in my case it was (LocalDb)\MSSQLLocalDB