Skip to content

Commit 77fce86

Browse files
author
Filipe GOMES PEIXOTO
committed
Drop support for EF Core 2.X
1 parent da17361 commit 77fce86

File tree

6 files changed

+30
-25
lines changed

6 files changed

+30
-25
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: csharp
22
mono: none
3-
dotnet: 3.0.100
3+
dotnet: 3.1.403
44

55
env:
66
global:

src/EntityFrameworkCore.DataEncryption/EntityFrameworkCore.DataEncryption.csproj

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

33
<PropertyGroup>
4-
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
4+
<TargetFrameworks>netstandard2.0</TargetFrameworks>
55
<AssemblyName>EntityFrameworkCore.DataEncryption</AssemblyName>
66
<RootNamespace>Microsoft.EntityFrameworkCore.DataEncryption</RootNamespace>
77
<Version>2.0.0</Version>
@@ -23,8 +23,7 @@
2323
</PropertyGroup>
2424

2525
<ItemGroup>
26-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" Condition="'$(TargetFramework)' == 'netstandard2.0'" />
27-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.0" Condition="'$(TargetFramework)' == 'netstandard2.1'" />
26+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
2827
</ItemGroup>
2928

3029
<ItemGroup>

src/EntityFrameworkCore.DataEncryption/ModelBuilderExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
using System;
2-
using Microsoft.EntityFrameworkCore.DataEncryption.Internal;
1+
using Microsoft.EntityFrameworkCore.DataEncryption.Internal;
32
using Microsoft.EntityFrameworkCore.Metadata;
43
using System;
54
using System.ComponentModel.DataAnnotations;

test/EntityFrameworkCore.DataEncryption.Test/Context/DatabaseContextFactory.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ public DatabaseContextFactory()
1919
{
2020
_connection = new SqliteConnection(DatabaseConnectionString);
2121
_connection.Open();
22-
23-
using (var dbContext = new DatabaseContext(CreateOptions<DatabaseContext>()))
24-
dbContext.Database.EnsureCreated();
2522
}
2623

2724
/// <summary>
@@ -32,10 +29,11 @@ public DatabaseContextFactory()
3229
/// <returns></returns>
3330
public TContext CreateContext<TContext>(IEncryptionProvider provider = null) where TContext : DbContext
3431
{
35-
if (provider == null)
36-
return Activator.CreateInstance(typeof(TContext), CreateOptions<TContext>()) as TContext;
32+
var context = Activator.CreateInstance(typeof(TContext), CreateOptions<TContext>(), provider) as TContext;
33+
34+
context.Database.EnsureCreated();
3735

38-
return Activator.CreateInstance(typeof(TContext), CreateOptions<TContext>(), provider) as TContext;
36+
return context;
3937
}
4038

4139
/// <summary>

test/EntityFrameworkCore.DataEncryption.Test/EntityFrameworkCore.DataEncryption.Test.csproj

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

33
<PropertyGroup>
4-
<TargetFrameworks>netcoreapp2.2;netcoreapp3.0;netcoreapp3.1</TargetFrameworks>
5-
4+
<TargetFramework>netcoreapp3.0</TargetFramework>
65
<IsPackable>false</IsPackable>
7-
86
<AssemblyName>Microsoft.EntityFrameworkCore.Encryption.Test</AssemblyName>
9-
107
<RootNamespace>Microsoft.EntityFrameworkCore.Encryption.Test</RootNamespace>
118
</PropertyGroup>
129

1310
<ItemGroup>
14-
<PackageReference Include="coverlet.msbuild" Version="2.7.0">
11+
<PackageReference Include="coverlet.msbuild" Version="2.9.0">
1512
<PrivateAssets>all</PrivateAssets>
1613
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1714
</PackageReference>
18-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
19-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.0" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
20-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.0.*" Condition="'$(TargetFramework)' == 'netcoreapp3.0'" />
21-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.0.*" Condition="'$(TargetFramework)' == 'netcoreapp3.0'" />
22-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.0" Condition="'$(TargetFramework)' == 'netcoreapp2.2'" />
23-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.0" Condition="'$(TargetFramework)' == 'netcoreapp2.2'" />
24-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="3.1.0" />
17+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
2518
<PackageReference Include="xunit" Version="2.4.1" />
26-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
19+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
2720
<PrivateAssets>all</PrivateAssets>
2821
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
2922
</PackageReference>

test/EntityFrameworkCore.DataEncryption.Test/Providers/AesProviderTest.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using Microsoft.EntityFrameworkCore.DataEncryption.Providers;
22
using Microsoft.EntityFrameworkCore.DataEncryption.Test.Context;
33
using Microsoft.EntityFrameworkCore.DataEncryption.Test.Helpers;
4+
using System;
45
using System.Collections.Generic;
56
using System.Linq;
67
using System.Security.Cryptography;
@@ -63,6 +64,15 @@ public void CompareTwoAesKeysInstancesTest(AesKeySize keySize)
6364
Assert.False(encryptionKeyInfo1.Equals(0));
6465
}
6566

67+
[Fact]
68+
public void CreateDataContextWithoutProvider()
69+
{
70+
using (var contextFactory = new DatabaseContextFactory())
71+
{
72+
Assert.Throws<ArgumentNullException>(() => contextFactory.CreateContext<SimpleEncryptedDatabaseContext>());
73+
}
74+
}
75+
6676
[Fact]
6777
public void EncryptUsingAes128Provider()
6878
{
@@ -137,5 +147,11 @@ public class Aes256EncryptedDatabaseContext : DatabaseContext
137147
public Aes256EncryptedDatabaseContext(DbContextOptions options, IEncryptionProvider encryptionProvider = null)
138148
: base(options, encryptionProvider) { }
139149
}
150+
151+
public class SimpleEncryptedDatabaseContext : DatabaseContext
152+
{
153+
public SimpleEncryptedDatabaseContext(DbContextOptions options, IEncryptionProvider encryptionProvider = null)
154+
: base(options, encryptionProvider) { }
155+
}
140156
}
141157
}

0 commit comments

Comments
 (0)