Skip to content

Commit 74a8f04

Browse files
authored
Users/henkkin/update to net5 (#3)
* Update to .net 5
1 parent 78b1a7d commit 74a8f04

19 files changed

+124
-148
lines changed

DataAccessClient.EntityFrameworkCore.SqlServer.Tests/DataAccessClient.EntityFrameworkCore.SqlServer.Tests.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.3" />
12-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
13-
<PackageReference Include="Moq" Version="4.13.1" />
14-
<PackageReference Include="Moq.AutoMock" Version="1.2.0.120" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-rc.2.*" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0-rc.2.*" />
12+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201020-06" />
13+
<PackageReference Include="Moq" Version="4.15.1" />
14+
<PackageReference Include="Moq.AutoMock" Version="2.1.0" />
1515
<PackageReference Include="xunit" Version="2.4.1" />
16-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
16+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1717
<PrivateAssets>all</PrivateAssets>
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1919
</PackageReference>
20-
<PackageReference Include="coverlet.collector" Version="1.2.1">
20+
<PackageReference Include="coverlet.collector" Version="1.3.0">
2121
<PrivateAssets>all</PrivateAssets>
2222
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2323
</PackageReference>

DataAccessClient.EntityFrameworkCore.SqlServer/Configuration/EntityBehaviors/SoftDeletableEntityBehaviorConfiguration.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private void RemoveSoftDeletableProperties(SqlServerDbContext serverDbContext, E
169169
var navigationPropertiesEntries = entityEntry.Navigations;
170170
foreach (var navigationEntry in navigationPropertiesEntries)
171171
{
172-
if (navigationEntry.Metadata.IsCollection())
172+
if (navigationEntry.Metadata.IsCollection)
173173
{
174174
if (navigationEntry.CurrentValue is ICollection collection)
175175
{

DataAccessClient.EntityFrameworkCore.SqlServer/DataAccessClient.EntityFrameworkCore.SqlServer.csproj

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
<PackageReleaseNotes></PackageReleaseNotes>
1414
<Copyright>Henk Kin</Copyright>
1515
<PackageTags>EntityFrameworkCore, EF, SqlServer, DependencyInjection, Multiple DbContext support, DataAccess, Repository, UnitOfWork, SoftDelete, Translation, Localization, RowVersioning, Multitenancy, Filtering, Paging, Sorting, Includes</PackageTags>
16-
<Version>0.0.8</Version>
16+
<Version>5.0.0</Version>
1717
<PublishRepositoryUrl>true</PublishRepositoryUrl>
1818
<EmbedUntrackedSources>true</EmbedUntrackedSources>
1919
<IncludeSymbols>true</IncludeSymbols>
2020
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2121
</PropertyGroup>
2222
<ItemGroup>
23-
<PackageReference Include="EntityCloner.Microsoft.EntityFrameworkCore" Version="0.0.2" />
24-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
25-
<PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="3.0.0" />
26-
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.5.0" />
27-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.3" />
23+
<PackageReference Include="EntityCloner.Microsoft.EntityFrameworkCore" Version="5.0.0" />
24+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.0-beta-20204-02" PrivateAssets="All" />
25+
<PackageReference Include="LinqKit.Microsoft.EntityFrameworkCore" Version="5.0.20" />
26+
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.8.0-5.final" />
27+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.0" />
2828
</ItemGroup>
2929

3030
<ItemGroup>

DataAccessClient.EntityFrameworkCore.SqlServer/Extensions/QueryableExtensions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ internal static async Task<CriteriaResult<T>> ToCriteriaResultAsync<T>(this IQue
5151
var options = ScriptOptions.Default.AddReferences(typeof(T).Assembly);
5252

5353
Expression<Func<T, bool>> whereClauseFunc =
54-
CSharpScript.EvaluateAsync<Expression<Func<T, bool>>>(whereClause, options).Result;
54+
await CSharpScript.EvaluateAsync<Expression<Func<T, bool>>>(whereClause, options);
5555

5656
source = source.Where(whereClauseFunc);
5757
}

DataAccessClient.EntityFrameworkCore.SqlServer/SqlServerDbContext.cs

Lines changed: 2 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@
1515

1616
namespace DataAccessClient.EntityFrameworkCore.SqlServer
1717
{
18-
public abstract class SqlServerDbContext : DbContext, IDbContextPoolable
18+
public abstract class SqlServerDbContext : DbContext, IResettableService
1919
{
2020
private static readonly MethodInfo DbContextResetStateMethodInfo;
2121
private static readonly MethodInfo DbContextResetStateAsyncMethodInfo;
22-
private static readonly MethodInfo DbContextResurrectMethodInfo;
2322
internal static ConcurrentBag<Type> RegisteredDbContextTypes = new ConcurrentBag<Type>();
2423
internal static ConcurrentDictionary<Type, List<Type>> RegisteredEntityTypesPerDbContexts = new ConcurrentDictionary<Type, List<Type>>();
2524

@@ -31,9 +30,6 @@ static SqlServerDbContext()
3130
DbContextResetStateAsyncMethodInfo = typeof(DbContext).GetMethod(
3231
$"{typeof(IResettableService).FullName}.{nameof(IResettableService.ResetStateAsync)}",
3332
BindingFlags.Instance | BindingFlags.NonPublic);
34-
DbContextResurrectMethodInfo = typeof(DbContext).GetMethod(
35-
$"{typeof(IDbContextPoolable).FullName}.{nameof(IDbContextPoolable.Resurrect)}",
36-
BindingFlags.Instance | BindingFlags.NonPublic);
3733
}
3834

3935
internal SqlServerDbContextExecutionContext ExecutionContext { get; private set; }
@@ -51,42 +47,11 @@ protected SqlServerDbContext(DbContextOptions options)
5147
_dbContextResetStateAsyncMethod =
5248
DbContextResetStateAsyncMethodInfo.CreateDelegate(typeof(Func<CancellationToken, Task>), this) as
5349
Func<CancellationToken, Task>;
54-
_dbContextResurrectMethod =
55-
DbContextResurrectMethodInfo.CreateDelegate(typeof(Action<DbContextPoolConfigurationSnapshot>), this) as
56-
Action<DbContextPoolConfigurationSnapshot>;
57-
5850
DataAccessClientOptionsExtension = options.FindExtension<DataAccessClientOptionsExtension>();
5951
}
6052

61-
#region DbContextPooling
62-
63-
// https://stackoverflow.com/questions/37310896/overriding-explicit-interface-implementations
64-
65-
/// <summary>
66-
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
67-
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
68-
/// any release. You should only use it directly in your code with extreme caution and knowing that
69-
/// doing so can result in application failures when updating to a new Entity Framework Core release.
70-
/// </summary>
71-
void IDbContextPoolable.Resurrect(DbContextPoolConfigurationSnapshot configurationSnapshot)
72-
{
73-
if (_dbContextResurrectMethod != null)
74-
{
75-
_dbContextResurrectMethod.Invoke(configurationSnapshot);
76-
}
77-
else
78-
{
79-
throw new InvalidOperationException(
80-
$"Cannot find method {nameof(IDbContextPoolable)}.{nameof(IDbContextPoolable.Resurrect)} on basetype DbContext of {GetType().FullName}");
81-
}
82-
}
53+
#region IResettableService overrides to support DbContextPooling
8354

84-
/// <summary>
85-
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
86-
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
87-
/// any release. You should only use it directly in your code with extreme caution and knowing that
88-
/// doing so can result in application failures when updating to a new Entity Framework Core release.
89-
/// </summary>
9055
void IResettableService.ResetState()
9156
{
9257
ResetSqlServerDbContextState();
@@ -102,13 +67,6 @@ void IResettableService.ResetState()
10267
}
10368
}
10469

105-
/// <summary>
106-
/// This is an internal API that supports the Entity Framework Core infrastructure and not subject to
107-
/// the same compatibility standards as public APIs. It may be changed or removed without notice in
108-
/// any release. You should only use it directly in your code with extreme caution and knowing that
109-
/// doing so can result in application failures when updating to a new Entity Framework Core release.
110-
/// </summary>
111-
/// <param name="cancellationToken"> A <see cref="CancellationToken" /> to observe while waiting for the task to complete. </param>
11270
async Task IResettableService.ResetStateAsync(CancellationToken cancellationToken)
11371
{
11472
ResetSqlServerDbContextState();

DataAccessClient.Tests/DataAccessClient.Tests.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55

66
<IsPackable>false</IsPackable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.3" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.3" />
12-
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="3.1.3" />
13-
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="3.1.3" />
14-
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
15-
<PackageReference Include="Moq" Version="4.13.1" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="5.0.0-rc.2.*" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="5.0.0-rc.2.*" />
12+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0-rc.2.*" />
13+
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="5.0.0-rc.2.*" />
14+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.0-preview-20201020-06" />
15+
<PackageReference Include="Moq" Version="4.15.1" />
1616
<PackageReference Include="xunit" Version="2.4.1" />
17-
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.1">
17+
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
1818
<PrivateAssets>all</PrivateAssets>
1919
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2020
</PackageReference>
21-
<PackageReference Include="coverlet.collector" Version="1.2.1">
21+
<PackageReference Include="coverlet.collector" Version="1.3.0">
2222
<PrivateAssets>all</PrivateAssets>
2323
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2424
</PackageReference>

DataAccessClient/DataAccessClient.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
2121
</PropertyGroup>
2222
<ItemGroup>
23-
<PackageReference Include="EntityCloner.Microsoft.EntityFrameworkCore" Version="0.0.2" />
24-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All" />
23+
<PackageReference Include="EntityCloner.Microsoft.EntityFrameworkCore" Version="0.0.4" />
24+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.0-beta-20204-02" PrivateAssets="All" />
2525
</ItemGroup>
2626
</Project>

DataAccessClientExample/Controllers/ValuesController.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ public async Task<IActionResult> DisableSoftDeletable()
171171
OrderByDirection = OrderByDirection.Ascending,
172172
Page = 1,
173173
PageSize = 10,
174-
Search = "Updated"
174+
Search = "Henk"
175175
};
176176
criteria.Includes.Add("Translations");
177177

@@ -181,7 +181,7 @@ public async Task<IActionResult> DisableSoftDeletable()
181181
OrderByDirection = OrderByDirection.Ascending,
182182
Page = 1,
183183
PageSize = 10,
184-
Search = "Updated"
184+
Search = "Henk"
185185
};
186186

187187
CriteriaResult<ExampleEntity> exampleEntitiesSearchResults;
Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk.Web">
22

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.3">
8+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.0-rc.2.*">
99
<PrivateAssets>all</PrivateAssets>
1010
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1111
</PackageReference>
12-
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="3.1.3" />
12+
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.0-rc.2.*" />
1313

1414
</ItemGroup>
1515

@@ -19,8 +19,6 @@
1919

2020
<ItemGroup>
2121
<Folder Include="Migrations\" />
22-
<Folder Include="Migrations\ExampleDatabase\" />
23-
<Folder Include="Migrations\ExampleSecondDatabase\" />
2422
</ItemGroup>
2523

2624
</Project>

DataAccessClientExample/DataLayer/ExampleDbContext.cs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
1818
modelBuilder
1919
.Entity<ExampleEntityView>()
2020
.HasNoKey()
21-
.ToQuery(() =>
22-
// TODO: Query does not work without query side evaluation, thows invalidoperationexception, needs investigation
23-
(from exampleEntity in Set<ExampleEntity>()
24-
from exampleEntityTranslation in Set<ExampleEntityTranslation>().Where(st => st.TranslatedEntityId == exampleEntity.Id)
25-
select new ExampleEntityView
26-
{
27-
Id = exampleEntity.Id,
28-
LocaleId = exampleEntityTranslation.LocaleId,
29-
Name = exampleEntity.Name,
30-
Description = exampleEntityTranslation.Description
31-
}));
21+
.ToSqlQuery("SELECT e.Id, et.LocaleId, e.Name, et.Description FROM dbo.ExampleEntities e INNER JOIN dbo.ExampleEntityTranslation et ON e.Id = et.TranslatedEntityId");
3222

3323
base.OnModelCreating(modelBuilder);
3424
}

DataAccessClientExample/DataLayer/Migrations.readme.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
cd [path-to-repository]\DataAccessClient\DataAccessClientExample
44

5-
dotnet ef migrations Add [migrationname] --context ExampleDbContext --output-dir Migrations/ExampleDatabase
6-
dotnet ef migrations Add [migrationname] --context ExampleSecondDbContext --output-dir Migrations/ExampleSecondDatabase
5+
dotnet ef migrations Add Initial --context ExampleDbContext --output-dir Migrations/ExampleDatabase
6+
dotnet ef migrations Add Initial --context ExampleSecondDbContext --output-dir Migrations/ExampleSecondDatabase
77

88
dotnet ef database update --context ExampleDbContext
99
dotnet ef database update --context ExampleSecondDbContext

DataAccessClientExample/Migrations/ExampleDatabase/20200228131932_Initial.Designer.cs renamed to DataAccessClientExample/Migrations/ExampleDatabase/20201111195040_Initial.Designer.cs

Lines changed: 11 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

DataAccessClientExample/Migrations/ExampleDatabase/20200228131932_Initial.cs renamed to DataAccessClientExample/Migrations/ExampleDatabase/20201111195040_Initial.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,18 @@ protected override void Up(MigrationBuilder migrationBuilder)
1111
name: "ExampleEntities",
1212
columns: table => new
1313
{
14-
Id = table.Column<int>(nullable: false)
14+
Id = table.Column<int>(type: "int", nullable: false)
1515
.Annotation("SqlServer:Identity", "1, 1"),
16-
CreatedOn = table.Column<DateTime>(nullable: false),
17-
CreatedById = table.Column<int>(nullable: false),
18-
ModifiedOn = table.Column<DateTime>(nullable: true),
19-
ModifiedById = table.Column<int>(nullable: true),
20-
IsDeleted = table.Column<bool>(nullable: false),
21-
DeletedOn = table.Column<DateTime>(nullable: true),
22-
DeletedById = table.Column<int>(nullable: true),
23-
RowVersion = table.Column<byte[]>(rowVersion: true, nullable: true),
24-
TenantId = table.Column<int>(nullable: false),
25-
Name = table.Column<string>(nullable: true)
16+
Name = table.Column<string>(type: "nvarchar(max)", nullable: true),
17+
CreatedOn = table.Column<DateTime>(type: "datetime2", nullable: false),
18+
CreatedById = table.Column<int>(type: "int", nullable: false),
19+
ModifiedOn = table.Column<DateTime>(type: "datetime2", nullable: true),
20+
ModifiedById = table.Column<int>(type: "int", nullable: true),
21+
IsDeleted = table.Column<bool>(type: "bit", nullable: false),
22+
DeletedOn = table.Column<DateTime>(type: "datetime2", nullable: true),
23+
DeletedById = table.Column<int>(type: "int", nullable: true),
24+
RowVersion = table.Column<byte[]>(type: "rowversion", rowVersion: true, nullable: true),
25+
TenantId = table.Column<int>(type: "int", nullable: false)
2626
},
2727
constraints: table =>
2828
{
@@ -33,9 +33,9 @@ protected override void Up(MigrationBuilder migrationBuilder)
3333
name: "ExampleEntityTranslation",
3434
columns: table => new
3535
{
36-
LocaleId = table.Column<string>(nullable: false),
37-
TranslatedEntityId = table.Column<int>(nullable: false),
38-
Description = table.Column<string>(nullable: true)
36+
LocaleId = table.Column<string>(type: "nvarchar(450)", nullable: false),
37+
TranslatedEntityId = table.Column<int>(type: "int", nullable: false),
38+
Description = table.Column<string>(type: "nvarchar(max)", nullable: true)
3939
},
4040
constraints: table =>
4141
{

0 commit comments

Comments
 (0)