question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add DbContext Diagram fault in Blazor app

See original GitHub issue

Hi,

I’m currently developing a Blazor Server-side app. I’ve encountered an issue with the tool for adding the DB Context diagram. I can survive without the diagram, but I figured I’d report the issue as anyone with a similar setup would likely face it too.

Essentially the crux of it is: my solution has two projects - one is the actual web app and the other is my datalibrary. When I attempt to add the DB context diagram, I am met with the following exception:

Parameter name: processResult at async Task EFCorePowerTools.Handlers.ModelAnalyzerHandler.GenerateAsync(string outputPath, Project project, GenerationType generationType) System.ArgumentException: Error: Microsoft.EntityFrameworkCore.Design.OperationException: Unable to create an object of type ‘FIS2_DbContext’. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728 —> System.InvalidOperationException: Unable to resolve service for type 'Microsoft.EntityFrameworkCore.DbContextOptions1[DataLibrary.Models.FIS2_FranklinContext_AutoGenerated]' while attempting to activate 'DataLibrary.Models.FIS2_DbContext'. at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.ConstructorMatcher.CreateInstance(IServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.CreateInstance(IServiceProvider provider, Type instanceType, Object[] parameters) at Microsoft.Extensions.DependencyInjection.ActivatorUtilities.GetServiceOrCreateInstance(IServiceProvider provider, Type type) at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13() --- End of inner exception stack trace --- at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.<>c__DisplayClass21_4.<FindContextTypes>b__13() at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func1 factory) at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType) at Modelling.EfCoreModelBuilder.BuildResult(String outputPath, String startupOutputPath, Boolean generateDdl) in C:\Code\EFCorePowerTools\src\GUI\efpt30.core\EFCoreModelBuilder.cs:line 39 at Modelling.Program.Main(String[] args) in C:\Code\EFCorePowerTools\src\GUI\efpt30.core\Program.cs:line 57

Parameter name: processResult at async Task EFCorePowerTools.Handlers.ModelAnalyzerHandler.GenerateAsync(string outputPath, Project project, GenerationType generationType)

I think this is because FIS2_DbContext is a partial class that adds some bolt-ons to the auto-generated dbContext?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Andy-Corrigancommented, Dec 13, 2021

I’m slightly confused as to how that works, but it worked. I would’ve thought that the DbContext diagram would go in the project that has the DbContext, not the other one.

1reaction
ErikEJcommented, Dec 13, 2021

As I said: try: right click the Blazor project

Read more comments on GitHub >

github_iconTop Results From Across the Web

EF Core Power Tools EntityFrameworkCore.Design. ...
EF Core Power Tools EntityFrameworkCore.Design.OperationException suddenly occurring on "Add DbContext Diagram" ... I've been using EF Core Power ...
Read more >
unable to add a DbContext model diagram · Issue #132
I'm unable to add a DbContext model diagram. Not sure why that is so maybe someone can point me to a solution. Here...
Read more >
Handle errors in ASP.NET Core Blazor apps
This article describes how Blazor manages unhandled exceptions and how to develop apps that detect and handle errors.
Read more >
ASP.NET Core Blazor Server with Entity Framework Core ...
This article explains how to use Entity Framework Core (EF Core) in Blazor Server apps. Blazor Server is a stateful app framework.
Read more >
Bind data from SQL server in Blazor
Learn how to retrieve data from SQL server, bind it to Syncfusion DataGrid component using Entity Framework, and perform CRUD operations.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found