mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-31 03:50:08 -07:00
The move!
This commit is contained in:
parent
1daf480b1b
commit
25526cc4d9
1147 changed files with 85 additions and 8524 deletions
49
src/Ombi.Store/Context/OmbiContext.cs
Normal file
49
src/Ombi.Store/Context/OmbiContext.cs
Normal file
|
@ -0,0 +1,49 @@
|
|||
using System.IO;
|
||||
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();
|
||||
|
||||
#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
|
||||
|
||||
var file = File.ReadAllText("SqlTables.sql");
|
||||
#endif
|
||||
// Run Script
|
||||
|
||||
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<GlobalSettings> Entry(GlobalSettings settings)
|
||||
{
|
||||
return Entry(settings);
|
||||
}
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
optionsBuilder.UseSqlite("Data Source=Ombi.db");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue