-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathIDbContextManager.cs
More file actions
61 lines (51 loc) · 2.02 KB
/
Copy pathIDbContextManager.cs
File metadata and controls
61 lines (51 loc) · 2.02 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright (c) 2026 Phoenix Contact GmbH & Co. KG
// Licensed under the Apache License, Version 2.0
using Microsoft.EntityFrameworkCore;
namespace Moryx.Model;
/// <summary>
/// Global component for handling database contexts
/// </summary>
public interface IDbContextManager
{
/// <summary>
/// Found DbContext types
/// </summary>
IReadOnlyCollection<Type> Contexts { get; }
/// <summary>
/// Get configurator for the given context type
/// </summary>
IModelConfigurator GetConfigurator(Type contextType);
/// <summary>
/// Get configurator instance for the given context type
/// </summary>
IModelConfigurator GetConfigurator(Type contextType, Type configuratorType, DatabaseConfig databaseConfig);
/// <summary>
/// Get possible configurators for the given context type
/// </summary>
Type[] GetConfigurators(Type contextType);
/// <summary>
/// Get setup executor for a model
/// </summary>
IModelSetupExecutor GetSetupExecutor(Type contextType);
/// <summary>
/// Creates a database context with the default configuration
/// </summary>
/// <typeparam name="TContext">Database context type</typeparam>
/// <returns>Preconfigured instance of the given DbContext</returns>
TContext Create<TContext>()
where TContext : DbContext;
/// <summary>
/// Creates a database context with the given configuration
/// </summary>
/// <typeparam name="TContext">Database context type</typeparam>
/// <returns>Preconfigured instance of the given DbContext</returns>
TContext Create<TContext>(DatabaseConfig config)
where TContext : DbContext;
/// <summary>
/// Updates the database configurator for the given context type
/// </summary>
/// <param name="dbContextType">Database context type</param>
/// <param name="configuratorType">Configurator type</param>
/// <param name="dbConfig">Database config</param>
void UpdateConfig(Type dbContextType, Type configuratorType, DatabaseConfig dbConfig);
}