Updating Startup.cs

The first thing we have to do is to add the EntityFramework support and our ApplicationDbContext implementation to our application startup class. Open the Startup.cs file and update the ConfigureServices method in the following way (new lines are highlighted):

  public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();

// Add EntityFramework support for SqlServer.
services.AddEntityFrameworkSqlServer();

// Add ApplicationDbContext.
services.AddDbContext<ApplicationDbContext>(options =>

options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))

);
}

The new code will also require the following namespace references:

using Microsoft.EntityFrameworkCore;
using TestMakerFreeWebApp.Data;
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.80.100