Breaking

Sunday, December 22, 2019

What ConfigureServices() method does in Startup.cs?


Ans: This method is optional. It is the place to add services required by the application. For example, if you wish to use Entity Framework in your application then you can add in this method.

public void ConfigureServices(IServiceCollection services)  
{
    services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
    services.AddEntityFramework()
            .AddSqlServer()
            .AddDbContext<SchoolContext>();c
    // Add MVC services to the services container.
    services.AddMvc();

}

No comments:

Post a Comment