Skip to content

Files

Latest commit

0a82d00 · Nov 25, 2020

History

History
27 lines (19 loc) · 811 Bytes

README.md

File metadata and controls

27 lines (19 loc) · 811 Bytes

Swisschain.Extensions.EfCore Nuget library

Entity Framework Core extensions

Usage

To run DB schema migration on the service startup add next code to you DI container configuration:

services.AddEfCoreDbMigration(c =>
{
    c.UseDbContextFactory(s => s.GetRequiredService<MyDatabaseContext>());
});

It's reasonable to do this in the worker (background) unit. If your service has several background units, do it only in the single unit.

To run DB schema validtion on the service startup add next code to you DI container configuration:

services.AddEfCoreDbValidation(c =>
{
    c.UseDbContextFactory(s => s.GetRequiredService<MyDatabaseContext>());
});

It's reasonable to do this in API units and secondary worker units.