You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Ombi/src/Ombi.Store/Context/OmbiContext.cs

50 lines
1.4 KiB

using System;
using System.IO;
7 years ago
using System.Resources;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Ombi.Store.Entities;
namespace Ombi.Store.Context
{
public class OmbiContext : DbContext, IOmbiContext
{
private static bool _created;
public OmbiContext()
{
if (_created) return;
_created = true;
Database.EnsureCreated();
Database.Migrate();
7 years ago
#if DEBUG
var location = System.Reflection.Assembly.GetEntryAssembly().Location;
var directory = System.IO.Path.GetDirectoryName(location);
var file = File.ReadAllText(Path.Combine(directory,"SqlTables.sql"));
#else
7 years ago
var file = File.ReadAllText("SqlTables.sql");
7 years ago
#endif
// Run Script
7 years ago
Database.ExecuteSqlCommand(file, 0);
}
public DbSet<RequestBlobs> Requests { get; set; }
public DbSet<GlobalSettings> Settings { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<PlexContent> PlexContent { get; set; }
public EntityEntry<T> Entry<T>(T entry) where T : class
{
return base.Entry(entry);
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data Source=Ombi.db");
}
}
}