forked from Emill/Npgsql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNpgsqlDatabaseFactory.cs
More file actions
44 lines (39 loc) · 1.73 KB
/
NpgsqlDatabaseFactory.cs
File metadata and controls
44 lines (39 loc) · 1.73 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
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using JetBrains.Annotations;
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Infrastructure;
using Microsoft.Data.Entity.Relational.Migrations;
using Microsoft.Data.Entity.Utilities;
using Microsoft.Framework.Logging;
namespace Npgsql.EntityFramework7
{
public class NpgsqlDatabaseFactory : INpgsqlDatabaseFactory
{
private readonly DbContext _context;
private readonly INpgsqlDataStoreCreator _dataStoreCreator;
private readonly INpgsqlEFConnection _connection;
private readonly IMigrator _migrator;
private readonly ILoggerFactory _loggerFactory;
public NpgsqlDatabaseFactory(
[NotNull] DbContext context,
[NotNull] INpgsqlDataStoreCreator dataStoreCreator,
[NotNull] INpgsqlEFConnection connection,
[NotNull] IMigrator migrator,
[NotNull] ILoggerFactory loggerFactory)
{
Check.NotNull(context, nameof(context));
Check.NotNull(dataStoreCreator, nameof(dataStoreCreator));
Check.NotNull(connection, nameof(connection));
Check.NotNull(migrator, nameof(migrator));
Check.NotNull(loggerFactory, nameof(loggerFactory));
_context = context;
_dataStoreCreator = dataStoreCreator;
_connection = connection;
_migrator = migrator;
_loggerFactory = loggerFactory;
}
public virtual Database CreateDatabase()
=> new NpgsqlDatabase(_context, _dataStoreCreator, _connection, _migrator, _loggerFactory);
}
}