Skip to content

Commit cdba710

Browse files
authored
Merge pull request #51 from NikolayIT/migrate-to-3.1
Migration to ASP.NET Core 3.1
2 parents 7c229b4 + eccac2b commit cdba710

File tree

43 files changed

+456
-469
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+456
-469
lines changed

ASP.NET Core/Data/AspNetCoreTemplate.Data.Common/AspNetCoreTemplate.Data.Common.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113" PrivateAssets="all">
1717
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1818
</PackageReference>
19-
<PackageReference Include="System.ComponentModel.Annotations" Version="4.5.0" />
19+
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
2020
</ItemGroup>
2121

2222
</Project>

ASP.NET Core/Data/AspNetCoreTemplate.Data.Models/AspNetCoreTemplate.Data.Models.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>netstandard2.1</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
</PropertyGroup>
77

@@ -13,7 +13,7 @@
1313
</ItemGroup>
1414

1515
<ItemGroup>
16-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.0" />
16+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
1717
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113" PrivateAssets="all">
1818
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
1919
</PackageReference>

ASP.NET Core/Data/AspNetCoreTemplate.Data/AspNetCoreTemplate.Data.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.2</TargetFramework>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
55
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
66
<LangVersion>latest</LangVersion>
77
</PropertyGroup>
@@ -22,14 +22,17 @@
2222
</ItemGroup>
2323

2424
<ItemGroup>
25-
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.2.0" />
26-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
27-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.2.6" />
28-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.2.6">
25+
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="3.1.0" />
26+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="3.1.0">
27+
<PrivateAssets>all</PrivateAssets>
28+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
29+
</PackageReference>
30+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
31+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.0">
2932
<PrivateAssets>all</PrivateAssets>
3033
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
3134
</PackageReference>
32-
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="2.2.0" />
35+
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="3.1.0" />
3336
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.113" PrivateAssets="all">
3437
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
3538
</PackageReference>

ASP.NET Core/Data/AspNetCoreTemplate.Data/DbQueryRunner.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,21 @@ public DbQueryRunner(ApplicationDbContext context)
1818

1919
public Task RunQueryAsync(string query, params object[] parameters)
2020
{
21-
return this.Context.Database.ExecuteSqlCommandAsync(query, parameters);
21+
return this.Context.Database.ExecuteSqlRawAsync(query, parameters);
2222
}
2323

2424
public void Dispose()
2525
{
26-
this.Context?.Dispose();
26+
this.Dispose(true);
27+
GC.SuppressFinalize(this);
28+
}
29+
30+
protected virtual void Dispose(bool disposing)
31+
{
32+
if (disposing)
33+
{
34+
this.Context?.Dispose();
35+
}
2736
}
2837
}
2938
}

ASP.NET Core/Data/AspNetCoreTemplate.Data/DesignTimeDbContextFactory.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
using Microsoft.EntityFrameworkCore;
66
using Microsoft.EntityFrameworkCore.Design;
7-
using Microsoft.EntityFrameworkCore.Diagnostics;
87
using Microsoft.Extensions.Configuration;
98

109
public class DesignTimeDbContextFactory : IDesignTimeDbContextFactory<ApplicationDbContext>
@@ -17,14 +16,9 @@ public ApplicationDbContext CreateDbContext(string[] args)
1716
.Build();
1817

1918
var builder = new DbContextOptionsBuilder<ApplicationDbContext>();
20-
2119
var connectionString = configuration.GetConnectionString("DefaultConnection");
22-
2320
builder.UseSqlServer(connectionString);
2421

25-
// Stop client query evaluation
26-
builder.ConfigureWarnings(w => w.Throw(RelationalEventId.QueryClientEvaluationWarning));
27-
2822
return new ApplicationDbContext(builder.Options);
2923
}
3024
}

ASP.NET Core/Data/AspNetCoreTemplate.Data/EfExpressionHelper.cs

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,8 @@ public static Expression<Func<TEntity, bool>> BuildByIdPredicate<TEntity>(
3131
}
3232

3333
var entityType = typeof(TEntity);
34-
3534
var entityParameter = Expression.Parameter(entityType, "e");
36-
3735
var keyProperties = dbContext.Model.FindEntityType(entityType).FindPrimaryKey().Properties;
38-
3936
var predicate = BuildPredicate(keyProperties, new ValueBuffer(id), entityParameter);
4037

4138
return Expression.Lambda<Func<TEntity, bool>>(predicate, entityParameter);
@@ -52,18 +49,14 @@ private static BinaryExpression BuildPredicate(
5249
for (var i = 0; i < keyProperties.Count; i++)
5350
{
5451
var property = keyProperties[i];
55-
var equalsExpression =
56-
Expression.Equal(
57-
Expression.Call(
58-
EfPropertyMethod.MakeGenericMethod(property.ClrType),
59-
entityParameter,
60-
Expression.Constant(property.Name, StringType)),
61-
Expression.Convert(
62-
Expression.Call(
63-
keyValuesConstant,
64-
ValueBufferGetValueMethod,
65-
Expression.Constant(i)),
66-
property.ClrType));
52+
var equalsExpression = Expression.Equal(
53+
Expression.Call(
54+
EfPropertyMethod.MakeGenericMethod(property.ClrType),
55+
entityParameter,
56+
Expression.Constant(property.Name, StringType)),
57+
Expression.Convert(
58+
Expression.Call(keyValuesConstant, ValueBufferGetValueMethod, Expression.Constant(i)),
59+
property.ClrType));
6760

6861
predicate = predicate == null ? equalsExpression : Expression.AndAlso(predicate, equalsExpression);
6962
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
namespace AspNetCoreTemplate.Data
2+
{
3+
using Microsoft.AspNetCore.Identity;
4+
5+
public static class IdentityOptionsProvider
6+
{
7+
public static void GetIdentityOptions(IdentityOptions options)
8+
{
9+
options.Password.RequireDigit = false;
10+
options.Password.RequireLowercase = false;
11+
options.Password.RequireUppercase = false;
12+
options.Password.RequireNonAlphanumeric = false;
13+
options.Password.RequiredLength = 6;
14+
}
15+
}
16+
}

0 commit comments

Comments
 (0)