forked from SimonCropp/GraphQL.EntityFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConfiguration.cs
38 lines (35 loc) · 981 Bytes
/
Configuration.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
36
37
38
using GraphQL.EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.Extensions.DependencyInjection;
class Configuration
{
#region ModelBuilder
static class ModelBuilder
{
public static IModel GetInstance()
{
var builder = new DbContextOptionsBuilder();
builder.UseSqlServer("Fake");
using var context = new MyDbContext(builder.Options);
return context.Model;
}
}
#endregion
void RegisterInContainerExplicit(IServiceCollection serviceCollection)
{
#region RegisterInContainer
EfGraphQLConventions.RegisterInContainer<MyDbContext>(
serviceCollection,
model: ModelBuilder.GetInstance());
#endregion
}
public class MyDbContext :
DbContext
{
public MyDbContext(DbContextOptions options) :
base(options)
{
}
}
}