EF Core ASP.NET Application
Registering the Context with Dependency Injection
To enable dependency injection for BullhornCRMContext, you must register it with the service container.
In newer ASP.NET Core projects (using the minimal hosting model), this is done in Program.cs.
In older projects, the code may go in Startup.cs.
using MySolutionName.Models;
using Microsoft.EntityFrameworkCore;
var connection = @"DataCenterCode=CLS33;OAuthClientId=myoauthclientid;OAuthClientSecret=myoauthclientsecret;InitiateOAuth=GETANDREFRESH;";
builder.Services.AddDbContext<BullhornCRMContext>(options =>
options.UseBullhornCRM(connection));
Creating a Controller and Views
To create a controller and views for your web app, follow these steps:
- Right-click the Controllers folder in the Solution Explorer and select Add -> Controller...
- Choose MVC Controller with views, using Entity Framework, and then click Add.
- Set the Model Class to the class corresponding to your table or view and set the Data context class to BullhornCRMContext.
- Click Add. Take note of the controller name.
Running Your Application
Once controller and views have been setup, you can launch your app by selecting Debug -> Start Without Debugging. Your browser opens automatically.
To view your data, navigate to <base URL>/<controller name without the "Controller" suffix>
For example, a controller named AccountController hosted on port 5001 would use the URL https://localhost:5001/Account.