|
5 | 5 | using System.Runtime.CompilerServices; |
6 | 6 | using System.Threading.Tasks; |
7 | 7 | using Microsoft.EntityFrameworkCore; |
8 | | -using Npgsql; |
9 | | -using Respawn; |
10 | 8 | using TestSupport.EfHelpers.Internal; |
11 | 9 | using TestSupport.Helpers; |
12 | 10 |
|
@@ -74,37 +72,6 @@ public static DbContextOptions<T> CreatePostgreSqlUniqueMethodOptions<T>(this ob |
74 | 72 | return CreatePostgreSqlOptionWithDatabaseName<T>(callingClass, callingMember, builder).Options; |
75 | 73 | } |
76 | 74 |
|
77 | | - //------------------------------------------------ |
78 | | - |
79 | | - /// <summary> |
80 | | - /// This will ensure that there is a PostgreSql database, and that database has no rows in any tables |
81 | | - /// NOTE: If you change anything that alters the database schema, then you must delete the database |
82 | | - /// and have EF Core recreate the database |
83 | | - /// </summary> |
84 | | - /// <typeparam name="T"></typeparam> |
85 | | - /// <param name="context"></param> |
86 | | - /// <param name="thereIsAnExistingDatabase">Optional: If you know that there is a database, then set this to true for a quicker clear of all the tables</param> |
87 | | - /// <returns></returns> |
88 | | - public async static Task EnsureCreatedAndEmptyPostgreSqlAsync<T>(this T context, bool thereIsAnExistingDatabase = false) |
89 | | - where T : DbContext |
90 | | - { |
91 | | - //see https://github.com/dotnet/efcore/issues/26541 for the solution |
92 | | - Checkpoint EmptyCheckpoint = new Checkpoint |
93 | | - { |
94 | | - DbAdapter = DbAdapter.Postgres |
95 | | - }; |
96 | | - |
97 | | - if (thereIsAnExistingDatabase || !context.Database.EnsureCreated()) |
98 | | - { |
99 | | - //the database already exists, so we just need to empty the tables |
100 | | - |
101 | | - var connectionString = context.Database.GetConnectionString(); |
102 | | - using var conn = new NpgsqlConnection(connectionString); |
103 | | - await conn.OpenAsync(); |
104 | | - await EmptyCheckpoint.Reset(conn); |
105 | | - }; |
106 | | - } |
107 | | - |
108 | 75 | //------------------------------------------------ |
109 | 76 | //private methods |
110 | 77 |
|
|
0 commit comments