How to view database diagram in a Code First using localdb
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.
- Open Management Studio (should have been installed with Visual Studio)
- Connect to
(localdb)\v11.0
, with Windows Authentication - Find the relevant database
- Expand Database Digrams, and install diagram support objects if you've not already
- 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.
Comments
-
Xaqron over 3 years
I have a
Code First
project withEntity Framework 5.0.0
usinglocaldb
created inVisual Studio 2012 Ultimate
. Although I can see my class relations in aClass Diagram
, how to see a visual diagram of automatic generated database byEF
? -
Ralph Lavelle over 11 yearsYeah, 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 about 11 yearsGood for now. It should support changes via model (currently it is read-only)
-
TimS over 10 yearsI 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 over 8 yearsThis 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 about 8 yearsor, just download Julie's .visx from here if you're in a rush.
-
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 almost 6 yearsFor 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