-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AddDbContext: Violates the constraint of type parameter 'TContext' #2309
Comments
There's a problem with running the generator from the "openapi" context (in CLI)... you need to somehow change the settings/exclude this EF registration when running NSwag from cli |
@RicoSuter I am using NSwagStudio and not the command line. |
This also uses the cli |
@RicoSuter OK thanks. Can you illustrate more on this pls?
|
When generating via CLI it might not find the appsettings.json and some services might not register correctly. An option is to check whether it's running in the nswag context and not register unnecessary services or use an nswag only startup.cs (a second one), just catch the exception and use that to find out in which context it's running, etc. |
I had this same issue when trying to use the LazyCache library - see alastairtree/LazyCache#186. In that case, it turned out to be because LazyCache expects to be the first library to register an |
Hi,
I have an ASP.NET Core 2.2 Web API app running fine in the browser. When I try to generate Typescript files in NSwagStudio, I get the following errors:
Here's the DbContext I have:
The text was updated successfully, but these errors were encountered: