Kros-sk / Kros.Libs

This repo contains Kros.Utils, Kros.Utils.MsAccess, Kros.KORM and Kros.KORM.MsAccess libraries.
MIT License
7 stars 13 forks source link

Features/kros.korm.extensions #164

Closed Burgyn closed 6 years ago

Burgyn commented 6 years ago

Closes #163

Created project Kros.KORM.Extensions.Asp for easier integration with ASP.NET Core projects.

You can use the AddKorm extension method to register IDatabase to the DI container.

public void ConfigureServices(IServiceCollection services)
{
    services.AddKorm(Configuration);
}

The configuration file (typically appsettings.json) must contain a section ConnectionString.

  "ConnectionString": {
    "ProviderName": "System.Data.SqlClient",
    "ConnectionString": "Server=servername\\instancename;Initial Catalog=database;Persist Security Info=False;"
  }

If you need to initialize the database for IIdGenerator then you can call InitDatabaseForIdGenerator.

public void ConfigureServices(IServiceCollection services)
{
    services.AddKorm(Configuration)
        .InitDatabaseForIdGenerator();
}