Month: September 2019

Seamless Integration

Adding AutoFac as Inversion of Control (IoC) mechanism in Asp.Net Core 2.2

Include AutoFac and Autofac.Extensions.DependencyInjection packages in your project 2. In the Startup Class, add an Autfac Container Object: 3. Build the Container and Register the Entities within the ConfigureServices method. Populate the .Net Core Services in the AutoFac Container 4. Return AutoFacServiceProvider and change the return type of ConfigureServices to IServiceProvider 5. Services within the …

Entity Framework Core in Asp.Net Core 2.2

Create a Database Context Class inherited from Microsoft.EntityFrameworkCore.DbContext and define DbSets with Database Models: 2. Create a ConnectionString in appsettings.json 3. In the Startup class, add database context to the Service Collection 4. Use the Database Context to query/execute SQL commands