-
-
Notifications
You must be signed in to change notification settings - Fork 298
Inspect your DbContext model
Erik Ejlskov Jensen edited this page Sep 28, 2024
·
21 revisions
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 visualize the schema of the chosen database. Requires the Visual Studio DGML viewer component (not available for ARM64)
Allows you to view the SQL CREATE script in order to create the current DbContext Model.
Since the tool needs to load the compiled .dll based on your project and instantiate your derived DbContext(s), there can be a number of challenges preventing/blocking this:
- You must be able to build the project 😄
- Make sure you have the correct Startup project set in Visual Studio (should be the web app or library project).
- Run the tool from a web app or library project.
- The model inspection tool (an external process launched by Visual Studio) can be blocked by a virus scanner or similar
- The model inspection tool requires a compatible .NET Core runtime to be installed.
- Your DbContext must be configured with a specific provider, or you will get this error: No database provider has been configured for this DbContext.
- Your DbContext must have a parameter less constructor, see sample or make other design time helpers available.
- If you cannot view the model graph, follow the advice here to install the viewer.
See this or use the AsDgml() extension method described below.