17 lines
623 B
C#
17 lines
623 B
C#
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using Microsoft.Extensions.DependencyInjection;
|
||
|
|
|
||
|
|
namespace EngineeringSync.Infrastructure;
|
||
|
|
|
||
|
|
public static class ServiceCollectionExtensions
|
||
|
|
{
|
||
|
|
public static IServiceCollection AddInfrastructure(this IServiceCollection services, string dbPath)
|
||
|
|
{
|
||
|
|
// WAL=Write-Ahead Logging: ermöglicht gleichzeitiges Lesen (API) und Schreiben (Watcher)
|
||
|
|
var connectionString = $"Data Source={dbPath};Mode=ReadWriteCreate;Cache=Shared";
|
||
|
|
services.AddDbContextFactory<AppDbContext>(options =>
|
||
|
|
options.UseSqlite(connectionString));
|
||
|
|
return services;
|
||
|
|
}
|
||
|
|
}
|