Skip to content

Commit 57d50cd

Browse files
committed
EFCore 5.x support added
1 parent b17b66d commit 57d50cd

11 files changed

Lines changed: 31 additions & 246 deletions

EntityFrameworkCore.Extensions.Samples/EntityFrameworkCore.Extensions.Samples.csproj

Lines changed: 1 addition & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -5,61 +5,6 @@
55
<TargetFramework>netcoreapp3.1</TargetFramework>
66
</PropertyGroup>
77

8-
<ItemGroup>
9-
<Compile Remove="Migrations\20200325195611_AddColumn.cs" />
10-
<Compile Remove="Migrations\20200325195611_AddColumn.Designer.cs" />
11-
<Compile Remove="Migrations\20200325195829_RemoveColumn.cs" />
12-
<Compile Remove="Migrations\20200325195829_RemoveColumn.Designer.cs" />
13-
<Compile Remove="Migrations\20200325195948_RemoveColumn.cs" />
14-
<Compile Remove="Migrations\20200325195948_RemoveColumn.Designer.cs" />
15-
<Compile Remove="Migrations\20200325202110_RemoveColumn.cs" />
16-
<Compile Remove="Migrations\20200325202110_RemoveColumn.Designer.cs" />
17-
<Compile Remove="Migrations\20200325202129_RemoveColumn2.cs" />
18-
<Compile Remove="Migrations\20200325202129_RemoveColumn2.Designer.cs" />
19-
<Compile Remove="Migrations\20200325202644_RemoveColumn4.cs" />
20-
<Compile Remove="Migrations\20200325202644_RemoveColumn4.Designer.cs" />
21-
<Compile Remove="Migrations\20200328124135_Remove.cs" />
22-
<Compile Remove="Migrations\20200328124135_Remove.Designer.cs" />
23-
<Compile Remove="Migrations\20200328124236_Remove.cs" />
24-
<Compile Remove="Migrations\20200328124236_Remove.Designer.cs" />
25-
<Compile Remove="Migrations\20200328124611_Remove123.cs" />
26-
<Compile Remove="Migrations\20200328124611_Remove123.Designer.cs" />
27-
<Compile Remove="Migrations\20200328132328_test.cs" />
28-
<Compile Remove="Migrations\20200328132328_test.Designer.cs" />
29-
<Compile Remove="Migrations\20200328135359_test1.cs" />
30-
<Compile Remove="Migrations\20200328135359_test1.Designer.cs" />
31-
<Compile Remove="Migrations\20200328142140_test1234.cs" />
32-
<Compile Remove="Migrations\20200328142140_test1234.Designer.cs" />
33-
<Compile Remove="Migrations\20200328142203_test123456.cs" />
34-
<Compile Remove="Migrations\20200328142203_test123456.Designer.cs" />
35-
<Compile Remove="Migrations\20200328143635_test123456.cs" />
36-
<Compile Remove="Migrations\20200328143635_test123456.Designer.cs" />
37-
<Compile Remove="Migrations\20200328143704_test123456sdf.cs" />
38-
<Compile Remove="Migrations\20200328143704_test123456sdf.Designer.cs" />
39-
<Compile Remove="Migrations\20200328143729_test123456sdfdfg.cs" />
40-
<Compile Remove="Migrations\20200328143729_test123456sdfdfg.Designer.cs" />
41-
<Compile Remove="Migrations\20200328143753_test123456sdfdfgsdf.cs" />
42-
<Compile Remove="Migrations\20200328143753_test123456sdfdfgsdf.Designer.cs" />
43-
<Compile Remove="Migrations\20200328150021_Sample1.cs" />
44-
<Compile Remove="Migrations\20200328150021_Sample1.Designer.cs" />
45-
<Compile Remove="Migrations\20200328150102_Sample1.cs" />
46-
<Compile Remove="Migrations\20200328150102_Sample1.Designer.cs" />
47-
<Compile Remove="Migrations\20200328150210_Sample2.cs" />
48-
<Compile Remove="Migrations\20200328150210_Sample2.Designer.cs" />
49-
<Compile Remove="Migrations\20200328151944_Sample2.cs" />
50-
<Compile Remove="Migrations\20200328151944_Sample2.Designer.cs" />
51-
<Compile Remove="Migrations\20200328152015_Sample3.cs" />
52-
<Compile Remove="Migrations\20200328152015_Sample3.Designer.cs" />
53-
<Compile Remove="Migrations\20200328152432_Sample4.cs" />
54-
<Compile Remove="Migrations\20200328152432_Sample4.Designer.cs" />
55-
<Compile Remove="Migrations\20200328152453_Sample6.cs" />
56-
<Compile Remove="Migrations\20200328152453_Sample6.Designer.cs" />
57-
<Compile Remove="Migrations\20200328152504_Sample8.cs" />
58-
<Compile Remove="Migrations\20200328152504_Sample8.Designer.cs" />
59-
<Compile Remove="Migrations\20200328152617_Sample1.cs" />
60-
<Compile Remove="Migrations\20200328152617_Sample1.Designer.cs" />
61-
</ItemGroup>
62-
638
<ItemGroup>
649
<ProjectReference Include="..\EntityFrameworkCore.Extensions\EntityFrameworkCore.Extensions.csproj" />
6510
</ItemGroup>
@@ -71,7 +16,7 @@
7116
</ItemGroup>
7217

7318
<ItemGroup>
74-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.2">
19+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.8">
7520
<PrivateAssets>all</PrivateAssets>
7621
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
7722
</PackageReference>

EntityFrameworkCore.Extensions.Samples/Migrations/20200328194818_Sample.Designer.cs

Lines changed: 0 additions & 89 deletions
This file was deleted.

EntityFrameworkCore.Extensions.Samples/Migrations/20200328194818_Sample.cs

Lines changed: 0 additions & 66 deletions
This file was deleted.

EntityFrameworkCore.Extensions.Samples/Migrations/SampleContextModelSnapshot.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
1515
{
1616
#pragma warning disable 612, 618
1717
modelBuilder
18-
.HasAnnotation("ProductVersion", "3.1.2")
1918
.HasAnnotation("Relational:MaxIdentifierLength", 128)
19+
.HasAnnotation("ProductVersion", "5.0.8")
2020
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
2121

2222
modelBuilder.Entity("EntityFrameworkCore.Extensions.Samples.Customer", b =>
@@ -34,7 +34,8 @@ protected override void BuildModel(ModelBuilder modelBuilder)
3434
.HasColumnType("nvarchar(max)");
3535

3636
b.Property<string>("Phone")
37-
.HasColumnType("nvarchar(max)");
37+
.HasColumnType("nvarchar(max)")
38+
.HasAnnotation("DynamicDataMasking", "partial(2, \"XX-XX\", 1)");
3839

3940
b.Property<string>("SampleProperty1")
4041
.HasColumnType("nvarchar(max)");
@@ -81,6 +82,11 @@ protected override void BuildModel(ModelBuilder modelBuilder)
8182
.HasForeignKey("CustomerId")
8283
.OnDelete(DeleteBehavior.Cascade);
8384
});
85+
86+
modelBuilder.Entity("EntityFrameworkCore.Extensions.Samples.Customer", b =>
87+
{
88+
b.Navigation("Orders");
89+
});
8490
#pragma warning restore 612, 618
8591
}
8692
}

EntityFrameworkCore.Extensions.Tests/DatabaseFacadeExtensionsTests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,11 @@ public string GenerateScript(string fromMigration = null, string toMigration = n
8686
{
8787
throw new NotImplementedException();
8888
}
89+
90+
public string GenerateScript(string fromMigration = null, string toMigration = null, MigrationsSqlGenerationOptions options = MigrationsSqlGenerationOptions.Default)
91+
{
92+
throw new NotImplementedException();
93+
}
8994
}
9095
}
9196
}

EntityFrameworkCore.Extensions.Tests/DbContextOptionsBuilderExtensionsTest.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using EntityFrameworkCore.Extensions.Services;
22
using Microsoft.EntityFrameworkCore;
33
using Microsoft.EntityFrameworkCore.Infrastructure;
4+
using Microsoft.EntityFrameworkCore.Metadata;
45
using Microsoft.EntityFrameworkCore.Migrations;
56
using System;
67
using Xunit;
@@ -19,10 +20,10 @@ public void UseEntityFrameworkCoreExtensions_should_register_necessary_services(
1920
var context = (IInfrastructure<IServiceProvider>)new TestContext(builder);
2021

2122
var migrationSqlGenerator = context.GetService<IMigrationsSqlGenerator>();
22-
var migrationAnnotationsProvider = context.GetService<IMigrationsAnnotationProvider>();
23+
var relationalAnnotationProvider = context.GetService<IRelationalAnnotationProvider>();
2324

2425
Assert.IsType<ExtendedMigrationSqlServerGenerator>(migrationSqlGenerator);
25-
Assert.IsType<ExtendedSqlServerMigrationsAnnotationProvider>(migrationAnnotationsProvider);
26+
Assert.IsType<ExtendedSqlServerAnnotationProvider>(relationalAnnotationProvider);
2627
}
2728
}
2829
}

EntityFrameworkCore.Extensions.Tests/EntityFrameworkCore.Extensions.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
</ItemGroup>
1616

1717
<ItemGroup>
18-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.2" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="5.0.8" />
1919
<PackageReference Include="Moq" Version="4.14.4" />
2020
<PackageReference Include="xunit" Version="2.4.1" />
2121
<PackageReference Include="xunit.runner.console" Version="2.4.1">

EntityFrameworkCore.Extensions/DbContextOptionsBuilderExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using EntityFrameworkCore.Extensions.Services;
22
using Microsoft.EntityFrameworkCore;
3+
using Microsoft.EntityFrameworkCore.Metadata;
34
using Microsoft.EntityFrameworkCore.Migrations;
45

56
namespace EntityFrameworkCore.Extensions
@@ -12,7 +13,7 @@ public static class DbContextOptionsBuilderExtensions
1213
public static DbContextOptionsBuilder UseEntityFrameworkCoreExtensions(this DbContextOptionsBuilder optionsBuilder)
1314
{
1415
optionsBuilder.ReplaceService<IMigrationsSqlGenerator, ExtendedMigrationSqlServerGenerator>();
15-
optionsBuilder.ReplaceService<IMigrationsAnnotationProvider, ExtendedSqlServerMigrationsAnnotationProvider>();
16+
optionsBuilder.ReplaceService<IRelationalAnnotationProvider, ExtendedSqlServerAnnotationProvider>();
1617

1718
return optionsBuilder;
1819
}

EntityFrameworkCore.Extensions/EntityFrameworkCore.Extensions.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<Authors>Nikita Savinov</Authors>
66
<Company>Nikita Savinov</Company>
77
<PackageProjectUrl>https://github.com/nikitasavinov/EntityFrameworkCore.Extensions</PackageProjectUrl>
88
<Description>A set of usefull extensions for EntityFrameworkCore (Dynamic data masking, MigrationBuilder and ModelBuilder extensions, etc)</Description>
99
<PackageRequireLicenseAcceptance>false</PackageRequireLicenseAcceptance>
10-
<Version>3.2.1</Version>
10+
<Version>5.0.0-beta</Version>
1111
<PackageTags>EntityFrameworkCore entity-framework-core DB data-masking</PackageTags>
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" />
16-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.2" />
17-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.2" />
18-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.2" />
19-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.2">
15+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.8" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.8" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="5.0.8" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.8" />
19+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="5.0.8">
2020
<PrivateAssets>all</PrivateAssets>
2121
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2222
</PackageReference>

EntityFrameworkCore.Extensions/Services/ExtendedMigrationSqlServerGenerator.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace EntityFrameworkCore.Extensions.Services
66
{
77
public class ExtendedMigrationSqlServerGenerator : SqlServerMigrationsSqlGenerator
88
{
9-
public ExtendedMigrationSqlServerGenerator(MigrationsSqlGeneratorDependencies dependencies, IMigrationsAnnotationProvider migrationsAnnotations) : base(dependencies, migrationsAnnotations)
9+
public ExtendedMigrationSqlServerGenerator(MigrationsSqlGeneratorDependencies dependencies, IRelationalAnnotationProvider relationalAnnotationProvider) : base(dependencies, relationalAnnotationProvider)
1010
{
1111
}
1212

@@ -71,10 +71,13 @@ private void AddMaskingFunction(AddColumnOperation column, MigrationCommandListB
7171

7272
private void DropMaskingFunction(AlterColumnOperation operation, MigrationCommandListBuilder builder)
7373
{
74+
var sqlHelper = Dependencies.SqlGenerationHelper;
75+
7476
builder.Append("ALTER TABLE ")
7577
.Append(Dependencies.SqlGenerationHelper.DelimitIdentifier(operation.Table, operation.Schema))
7678
.Append($" ALTER COLUMN {operation.Name}")
7779
.Append($" DROP MASKED")
80+
.Append(sqlHelper.StatementTerminator)
7881
.EndCommand();
7982
}
8083

0 commit comments

Comments
 (0)