tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
DesignTimeDbContextFactoryHelpers.cs
Go to the documentation of this file.
1using Microsoft.EntityFrameworkCore;
2using Microsoft.Extensions.Options;
3
5
7{
12 {
21 public static DbContextOptions<TDatabaseContext> CreateDatabaseContextOptions<TDatabaseContext>(
22 DatabaseType databaseType,
23 string connectionString,
24 string? serverVersion = null)
25 where TDatabaseContext : DatabaseContext
26 {
27 var dbConfig = new DatabaseConfiguration
28 {
29 DatabaseType = databaseType,
30 ConnectionString = connectionString,
31 ServerVersion = serverVersion,
32 };
33
34 var optionsFac = new DbContextOptionsBuilder<TDatabaseContext>();
35 var configureAction = DatabaseContext.GetConfigureAction<TDatabaseContext>();
36
37 configureAction(optionsFac, dbConfig);
38
39 return optionsFac.Options;
40 }
41 }
42}
Configuration options for the Database.DatabaseContext.
Backend abstract implementation of IDatabaseContext.
static DbContextOptions< TDatabaseContext > CreateDatabaseContextOptions< TDatabaseContext >(DatabaseType databaseType, string connectionString, string? serverVersion=null)
Get the IOptions<TOptions> for the DatabaseConfiguration.
DatabaseType
Type of database to user.