-
-
Notifications
You must be signed in to change notification settings - Fork 300
Inspect your DbContext model
Adds a DGML graph of the DbContext(s) in you project, that allows you to inspect the relationships and properties on your DbContext Model.
Allows you to view the SQL CREATE script in order to create the current DbContext Model.
You cannot use the two features above with .NET Standard 2.0 libraries, as this project type does not produce any executable build output.
The following workarounds are available:
- Target .NET Core 2.0 also:
<TargetFrameworks>netcoreapp2.0;netstandard2.0</TargetFrameworks>
(Notice the added "s"!) - TargetFrameworks
- Use the AsDgml() extension method described below.
This menu item installs a NuGet package, that adds the AsDgml() extension method to any derived DbContext.
The method will create a DGML graph of your DbContext Model, that you can view in the Visual Studio DGML viewer.
You can add code like this to in a Unit Test or similar to create the diagram:
using (var myContext = new MyDbContext())
{
var path = Path.GetTempFileName() + ".dgml";
File.WriteAllText(path, myContext.AsDgml(), Encoding.UTF8);
Process.Start(path);
}