tgstation-server  4.4.0
The /tg/station 13 server suite
SqlServerDatabaseContext.cs
Go to the documentation of this file.
1 using Microsoft.EntityFrameworkCore;
2 using System;
4 
5 namespace Tgstation.Server.Host.Database
6 {
11  {
16  public SqlServerDatabaseContext(DbContextOptions<SqlServerDatabaseContext> dbContextOptions) : base(dbContextOptions)
17  { }
18 
24  public static void ConfigureWith(DbContextOptionsBuilder options, DatabaseConfiguration databaseConfiguration)
25  {
26  if (options == null)
27  throw new ArgumentNullException(nameof(options));
28  if (databaseConfiguration == null)
29  throw new ArgumentNullException(nameof(databaseConfiguration));
30 
31  if (databaseConfiguration.DatabaseType != DatabaseType.SqlServer)
32  throw new InvalidOperationException($"Invalid DatabaseType for {nameof(SqlServerDatabaseContext)}!");
33 
34  options.UseSqlServer(databaseConfiguration.ConnectionString, x => x.EnableRetryOnFailure());
35  }
36  }
37 }
string ConnectionString
The connection string for the database
Backend abstract implementation of IDatabaseContext
DatabaseType DatabaseType
The Configuration.DatabaseType to create
static void ConfigureWith(DbContextOptionsBuilder options, DatabaseConfiguration databaseConfiguration)
Configure the SqlServerDatabaseContext.
SqlServerDatabaseContext(DbContextOptions< SqlServerDatabaseContext > dbContextOptions)
Construct a SqlServerDatabaseContext
Configuration options for the Database.DatabaseContext
DatabaseType
Type of database to user
Definition: DatabaseType.cs:6