Skip to content

Commit cb75b06

Browse files
committed
Version 8.2.0
1 parent 3a9e29d commit cb75b06

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

EfSchemaCompare/EfSchemaCompare.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
<Description>Useful tool if you are changing the schema of your database's schema outside of EF Core' migrations, say by using SQL change scripts. See readme file on github.</Description>
2727
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
2828
<PackageReleaseNotes>
29-
- The ExtraInDatabase errors didn't correctly say what part of the database (e.g. "Table", "Column") was extra. This is fixed.
30-
- NOTE: If you have ignored some ExtraInDatabase errors you our old ignored ExtraInDatabase might need updating to the new (correct format) pattern.
31-
- New boolean 'AlwaysRunStage2' in the CompareEfSqlConfig. If set to 'true', then Stage 2 will always run, even if there are non-ignored errors.
29+
- The ExtraInDatabase errors didn't correctly say what part of the database (e.g. "Table", "Column") was extra. This is fixed.
30+
- NOTE: If you have ignored some ExtraInDatabase errors you our old ignored ExtraInDatabase might need updating to the new (correct format) pattern.
31+
- New boolean 'AlwaysRunStage2' in the CompareEfSqlConfig. If set to 'true', then Stage 2 will always run, even if there are non-ignored errors. See issue #38, which made me add this new feature.
3232
</PackageReleaseNotes>
3333
<Copyright>Copyright (c) 2020 Jon P Smith. Licenced under MIT licence</Copyright>
3434
<PackageTags>Entity Framework Core, Database</PackageTags>

Test/UnitTests/TestExtraInDatabase.cs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,42 @@ public void DecodeCompareTextToCompareLog_ExtraIndexInDatabase_Test()
3030
compareLog.Type.ShouldEqual(CompareType.Index);
3131
}
3232

33+
[Theory]
34+
[InlineData(false, 1)]
35+
[InlineData(true, 3)]
36+
public void TestAlwaysRunStage2(bool runStage, int numErrors)
37+
{
38+
//SETUP
39+
var options = this.CreateUniqueClassOptions<BookContext>();
40+
using var context = new BookContext(options);
41+
context.Database.EnsureClean();
42+
43+
//Stage 1 error: Change Column on existing table
44+
var filepath1 = TestData.GetFilePath("RenameColumn.sql");
45+
context.ExecuteScriptFileInTransaction(filepath1);
46+
//Stage 2 error: Add new table
47+
var filepath2 = TestData.GetFilePath("AddExtraTable.sql");
48+
context.ExecuteScriptFileInTransaction(filepath2);
49+
50+
//ATTEMPT
51+
var config = new CompareEfSqlConfig
52+
{
53+
TablesToIgnoreCommaDelimited = "",
54+
AlwaysRunStage2 = runStage
55+
};
56+
var comparer = new CompareEfSql(config);
57+
var hasErrors = comparer.CompareEfWithDb(context);
58+
59+
//VERIFY
60+
hasErrors.ShouldBeTrue();
61+
var errors = comparer.GetAllErrors.Split("\r\n");
62+
foreach (var error in errors)
63+
{
64+
_output.WriteLine(error);
65+
}
66+
errors.Length.ShouldEqual(numErrors);
67+
}
68+
3369
[Fact]
3470
public void TestExtraTable()
3571
{

0 commit comments

Comments
 (0)