-
Notifications
You must be signed in to change notification settings - Fork 3
/
PostgreSqlMigrationSqlGeneretorHistoryTest.cs
71 lines (56 loc) · 2.2 KB
/
PostgreSqlMigrationSqlGeneretorHistoryTest.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System.Data.Entity.Infrastructure;
using System.Data.Entity.Migrations;
using System.Data.Entity;
using System.Data.Entity.Migrations.Sql;
using Npgsql;
using NUnit.Framework;
namespace EntityFramework.PostgreSql.Test.IntegrationTests
{
[TestFixture]
public class PostgreSqlMigrationSqlGeneretorHistoryTest
{
private const string ConnectionString = "Server=127.0.0.1;Port=5432;Database=testEF6;User Id=postgres;Password=p0o9i8u7y6;CommandTimeout=20;Preload Reader = true;";
private const string ProviderName = "Npgsql";
[Test]
public void GenerateInsertHistoryOperation()
{
var migrator = new DbMigrator(new LocalMigrationConfiguration());
migrator.Update();
}
public class LocalMigrationConfiguration : DbMigrationsConfiguration<LocalPgContext>
{
public LocalMigrationConfiguration()
{
AutomaticMigrationDataLossAllowed = true;
AutomaticMigrationsEnabled = false;
SetSqlGenerator("Npgsql", new PostgreSqlMigrationSqlGenerator());
MigrationsNamespace = "EntityFramework.PostgreSql.Test.IntegrationTests.Migrations";
MigrationsAssembly = typeof (LocalPgContext).Assembly;
TargetDatabase = new DbConnectionInfo(ConnectionString, ProviderName);
}
}
public class LocalPgContext : DbContext//, IDbProviderFactoryResolver, IDbConnectionFactory
{/*
public DbProviderFactory ResolveProviderFactory(DbConnection connection)
{
return DbProviderFactories.GetFactory("Npgsql");
}
public DbConnection CreateConnection(string nameOrConnectionString)
{
return new NpgsqlConnection(nameOrConnectionString);
}*/
}
/*
public class LocalConfiguration : DbConfiguration
{
public LocalConfiguration()
{
// can't set this cos NpgsqlServices is internal
SetProviderServices(
"Npgsql", provider: NpgsqlServices.Instance
);
}
}
*/
}
}