Skip to content

Commit 53a243d

Browse files
Rich-OttRichard Otttonysneed
authored
Update to EF Core 6 (#190)
* Remove the EnableNullableReferenceTypes Handlebars option in favor of using the built-in option for UseNullableReferenceTypes. * Add ManyToMany/SkipNavigation scaffolding. * Update to .NET 6. Co-authored-by: Richard Ott <richard.ott@roehl.net> Co-authored-by: Anthony Sneed <2836367+tonysneed@users.noreply.github.com>
1 parent 015cbe8 commit 53a243d

File tree

36 files changed

+873
-192
lines changed

36 files changed

+873
-192
lines changed

sample/ScaffoldingSample.Api/ScaffoldingSample.Api.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

sample/ScaffoldingSample.Embedded/ScaffoldingSample.Embedded.csproj

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

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

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.9" />
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0" />
1111
</ItemGroup>
1212

1313
<ItemGroup>

sample/ScaffoldingSample.TypeScript/CodeTemplates/TypeScriptEntityType/Partials/Properties.hbs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,13 @@
1414
{{nav-property-name}}: {{nav-property-type}};
1515
{{/if}}
1616
{{/each}}
17+
{{/if}}
18+
{{#if skip-nav-properties}}
19+
{{#each skip-nav-properties}}
20+
{{#if nav-property-collection}}
21+
{{nav-property-name}}: {{nav-property-type}}[];
22+
{{else}}
23+
{{nav-property-name}}: {{nav-property-type}};
24+
{{/if}}
25+
{{/each}}
1726
{{/if}}

sample/ScaffoldingSample.TypeScript/ScaffoldingSample.TypeScript.csproj

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

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

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.9" />
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0" />
1111
</ItemGroup>
1212

1313
<ItemGroup>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{{#each dbsets}}
22
{{my-helper}}
3-
public virtual DbSet<{{set-property-type}}> {{set-property-name}} { get; set; }{{#if nullable-reference-types }} = default!;{{/if}}
3+
public virtual DbSet<{{set-property-type}}> {{set-property-name}} { get; set; }{{#if nullable-reference-types }} = null!;{{/if}}
44
{{/each}}

sample/ScaffoldingSample/CodeTemplates/CSharpEntityType/Partials/Properties.hbs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
{{#each property-annotations}}
99
{{{property-annotation}}}
1010
{{/each}}
11-
public {{property-type}} {{property-name}} { get; set; }{{#if nullable-reference-types }}{{#unless property-isnullable}} = default!;{{/unless}}{{/if}}
11+
public {{property-type}} {{property-name}} { get; set; }{{#if nullable-reference-types }}{{#unless property-isnullable}} = null!;{{/unless}}{{/if}}
1212
{{/each}}
1313
{{#if nav-properties}}
1414

@@ -17,9 +17,22 @@
1717
{{{nav-property-annotation}}}
1818
{{/each}}
1919
{{#if nav-property-collection}}
20-
public virtual ICollection<{{nav-property-type}}> {{nav-property-name}} { get; set; }{{#if nullable-reference-types}} = default!;{{/if}}
20+
public virtual ICollection<{{nav-property-type}}> {{nav-property-name}} { get; set; }
2121
{{else}}
22-
public virtual {{nav-property-type}} {{nav-property-name}} { get; set; }{{#if nullable-reference-types}}{{#unless nav-property-isnullable}} = default!;{{/unless}}{{/if}}
22+
public virtual {{nav-property-type}} {{nav-property-name}} { get; set; }{{#if nullable-reference-types}}{{#unless nav-property-isnullable}} = null!;{{/unless}}{{/if}}
23+
{{/if}}
24+
{{/each}}
25+
{{/if}}
26+
{{#if skip-nav-properties}}
27+
28+
{{#each skip-nav-properties}}
29+
{{#each nav-property-annotations}}
30+
{{{nav-property-annotation}}}
31+
{{/each}}
32+
{{#if nav-property-collection}}
33+
public virtual ICollection<{{nav-property-type}}> {{nav-property-name}} { get; set; }
34+
{{else}}
35+
public virtual {{nav-property-type}} {{nav-property-name}} { get; set; }{{#if nullable-reference-types}}{{#unless nav-property-isnullable}} = null!;{{/unless}}{{/if}}
2336
{{/if}}
2437
{{/each}}
2538
{{/if}}

sample/ScaffoldingSample/ScaffoldingDesignTimeServices.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@ public void ConfigureDesignTimeServices(IServiceCollection services)
2727
// Generate both context and entities
2828
options.ReverseEngineerOptions = ReverseEngineerOptions.DbContextAndEntities;
2929

30-
// Enable Nullable reference types Support https://docs.microsoft.com/en-us/ef/core/miscellaneous/nullable-reference-types
31-
options.EnableNullableReferenceTypes = true;
32-
3330
// Put Models into folders by DB Schema
3431
options.EnableSchemaFolders = true;
3532

sample/ScaffoldingSample/ScaffoldingSample.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp3.1</TargetFramework>
4+
<TargetFramework>net6.0</TargetFramework>
55
<LangVersion>latest</LangVersion>
66
<Nullable>enable</Nullable>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="5.0.9" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="5.0.9" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0" />
1212
</ItemGroup>
1313

1414
<ItemGroup>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{{#each dbsets}}
2-
public virtual DbSet<{{set-property-type}}> {{set-property-name}} { get; set; }{{#if nullable-reference-types }} = default!;{{/if}}
2+
public virtual DbSet<{{set-property-type}}> {{set-property-name}} { get; set; }{{#if nullable-reference-types }} = null!;{{/if}}
33
{{/each}}

sample/TemplatesAssembly/CodeTemplates/CSharpEntityType/Class.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace {{namespace}}
44
{
55
{{#if comment}}
66
/// <summary>
7-
/// {{comment}}
7+
{{comment}}
88
/// </summary>
99
{{/if}}
1010
{{#each class-annotations}}

0 commit comments

Comments
 (0)