Bean0341 Bean0341 - 1 year ago 152
C# Question api dependency injection location

I am following a tutorial on web api and mongodb here and on step 4 it talks about dependency injection and adding it to the start.cs in the

method, however this doesnt seem to exist anymore. My web api templates startup.cs looks something like this...

public partial class Startup
public void Configuration(IAppBuilder app)

So my question is where do I inject my DataAccess class to my web api project as a service? Thanks in advance.

As requested here is my api structure

enter image description here

under LGR.API is the auto generated folders and classes created by visual studios and starting a LGR.Datamodel is my custom class with my api stuff. Really new here... not sure if this correct at all. Feel free to critique with best practices as necessary

Answer Source

It looks like you've created an ASP.NET application, and your tutorial is for ASP.NET Core. Recreate your project and pick the "ASP.NET Core Web Application" template.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download