Unable to create an object of type 'JsonContext'
I have fought this error for about an hour and finally gave up - would like a second set of eyes.
I wanted to use
dotnet ef migrations add InitialCreate
which prompted this error
Could you kindly point me in the right direction?
https://pastebin.com/GuxUApaWPastebin
The full error message:(base) MacBook-Pro-2:CRUDOnepager_Sample ann...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
3 Replies
why do you have this?
first of all, you can't call that at that point in the context's lifetime
second, EnsureCreated is not compatible with migrations
as for the actual error, you need a constructor that accepts a DbContextOptions<JsonContext> and passes it to the base exactly like the message says
Also, no need for
AddScoped<JsonContext>();
when you already do AddDbContext<JsonContext>()
So I removed parameterless JsonContext() with Database.EnsureCreated(). Those were replaced with
but the error persists (
Unable to create an object of type 'JsonContext'. For the different patterns supported at design time, see `https://go.microsoft.com/fwlink/?linkid=851728)
No idea what triggerd this error. Do you have any idea?Search - Microsoft Bing
Ready to let off some steam?
'A Festivus for the rest of us!' This is the unoff