forked from imperial-space/space-station14-public
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDesignTimeContextFactories.cs
35 lines (28 loc) · 1.05 KB
/
DesignTimeContextFactories.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#if TOOLS
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design;
using SQLitePCL;
// ReSharper disable UnusedType.Global
namespace Content.Server.Database;
public sealed class DesignTimeContextFactoryPostgres : IDesignTimeDbContextFactory<PostgresServerDbContext>
{
public PostgresServerDbContext CreateDbContext(string[] args)
{
var optionsBuilder = new DbContextOptionsBuilder<PostgresServerDbContext>();
optionsBuilder.UseNpgsql("Server=localhost");
return new PostgresServerDbContext(optionsBuilder.Options);
}
}
public sealed class DesignTimeContextFactorySqlite : IDesignTimeDbContextFactory<SqliteServerDbContext>
{
public SqliteServerDbContext CreateDbContext(string[] args)
{
#if !USE_SYSTEM_SQLITE
raw.SetProvider(new SQLite3Provider_e_sqlite3());
#endif
var optionsBuilder = new DbContextOptionsBuilder<SqliteServerDbContext>();
optionsBuilder.UseSqlite("Data Source=:memory:");
return new SqliteServerDbContext(optionsBuilder.Options);
}
}
#endif