25 lines
901 B
C#
25 lines
901 B
C#
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace PiwigoDirectorySync.Persistence;
|
|
|
|
public class PersistenceContext : DbContext
|
|
{
|
|
public DbSet<PiwigoServerEntity> PiwigoServers { get; set; } = null!;
|
|
public DbSet<AlbumEntity> PiwigoAlbums { get; set; } = null!;
|
|
public DbSet<ImageEntity> PiwigoImages { get; set; } = null!;
|
|
|
|
protected override void OnConfiguring(DbContextOptionsBuilder options)
|
|
{
|
|
switch (AppSettings.Settings.DbProvider)
|
|
{
|
|
case "Sqlite":
|
|
options.UseSqlite(AppSettings.ConnectionString);
|
|
break;
|
|
case "InMemory":
|
|
options.UseInMemoryDatabase(AppSettings.ConnectionString);
|
|
break;
|
|
default:
|
|
throw new InvalidOperationException($"DbProvider {AppSettings.Settings.DbProvider} is not supported");
|
|
}
|
|
}
|
|
} |