tgstation-server 6.12.0
The /tg/station 13 server suite
Loading...
Searching...
No Matches
SqlServerDatabaseContext.cs
Go to the documentation of this file.
1using System;
2
3using Microsoft.EntityFrameworkCore;
4
6
8{
13 {
18 public SqlServerDatabaseContext(DbContextOptions<SqlServerDatabaseContext> dbContextOptions)
19 : base(dbContextOptions)
20 {
21 }
22
28 public static void ConfigureWith(DbContextOptionsBuilder options, DatabaseConfiguration databaseConfiguration)
29 {
30 ArgumentNullException.ThrowIfNull(options);
31 ArgumentNullException.ThrowIfNull(databaseConfiguration);
32
33 if (databaseConfiguration.DatabaseType != DatabaseType.SqlServer)
34 throw new InvalidOperationException($"Invalid DatabaseType for {nameof(SqlServerDatabaseContext)}!");
35
36 options.UseSqlServer(
37 databaseConfiguration.ConnectionString,
38 sqlServerOptions =>
39 {
40 sqlServerOptions.EnableRetryOnFailure();
41 sqlServerOptions.UseQuerySplittingBehavior(QuerySplittingBehavior.SingleQuery);
42 });
43 }
44 }
45}
Configuration options for the Database.DatabaseContext.
string? ConnectionString
The connection string for the database.
DatabaseType DatabaseType
The Configuration.DatabaseType to create.
Backend abstract implementation of IDatabaseContext.
SqlServerDatabaseContext(DbContextOptions< SqlServerDatabaseContext > dbContextOptions)
Initializes a new instance of the SqlServerDatabaseContext class.
static void ConfigureWith(DbContextOptionsBuilder options, DatabaseConfiguration databaseConfiguration)
Configure the SqlServerDatabaseContext.
DatabaseType
Type of database to user.