I am trying to convert a .NET Framework web application to a .NET Core web application. I did start a new project, so I'm copying over info.
In th...
For further actions, you may consider blocking this person and/or reporting abuse
So I did get it working for anybody else that runs across this.
Previously, the following would work in .NET Framework: (On the controller - HikerController in my case)
Now in .NET Core, you need a constructor; starts a similar way:
Then you would reference database info something like this:
_context.Hikers....I have the following to display all of my hikers:
*If you don't use a constructor and pass in the
ApplicationDbContext, you will get the following:It’s a little hard to tell but the only thing I can think of is that your view is expecting a model but you’re not providing one.
What I have for the Hikers view, which should display all of the hikers. Shouldn't that first line do the trick?
If I set up an empty view, and link to it, it gets there just fine. Once I add database info, then it fails.
UPDATE:
So I have added this since, but I am faced with another error.
Error reads:
Glad you fixed the issue with the model. Unfortunately I'm not going to be able to help with the latter issue but I'd imagine the best place to start is the Entity Framework Core docs: docs.microsoft.com/en-us/ef/core/