Skip to content

Commit ada2bf8

Browse files
committed
Remove skip-nav-properties from Properties.hbs.
Fix GenerateImports in TypeScript entity generator. Update version to 6.0.0-preview2. Mark EnableNullableReferenceTypes as obsolete. Update ReadMe with v6 upgrade instructions.
1 parent 71482ca commit ada2bf8

File tree

19 files changed

+84
-74
lines changed

19 files changed

+84
-74
lines changed

README.md

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ Before creating a pull request, please refer to the [Contributing Guidelines](ht
1414

1515
## Prerequisites
1616

17-
- [Visual Studio 2022](https://www.visualstudio.com/downloads/) or greater.
18-
- [.NET Core 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) RC2 or greater.
17+
- [Visual Studio 2022](https://www.visualstudio.com/downloads/) or greater, [JetBrains Rider](https://www.jetbrains.com/rider) 2021.3 or greater.
18+
- [.NET Core 6.0 SDK](https://dotnet.microsoft.com/download/dotnet/6.0) or greater.
1919
- [EF Core CLI 6.0](https://docs.microsoft.com/en-us/ef/core/cli/dotnet) or greater.
2020
- Install global `dotnet-ef` tool.
2121
```
2222
dotnet tool install --global dotnet-ef
2323
```
24-
- Update global `dotnet-ef` tool.
24+
- Or update global `dotnet-ef` tool.
2525
```
2626
dotnet tool update --global dotnet-ef
2727
```
@@ -35,6 +35,21 @@ Before creating a pull request, please refer to the [Contributing Guidelines](ht
3535
- Download the `NorthwindSlim.sql` file from <https://github.com/TrackableEntities/northwind-slim>.
3636
- Unzip **NorthwindSlim.sql** and run the script to create tables and populate them with data.
3737
38+
## Upgrading from v5 to v6
39+
40+
1. Upgrade `TargetFramework` in **.csproj** file to `net6.0`.
41+
- Optional: Set `ImplicitUsings` to `enable`.
42+
- Optional: Set `Nullable` ro `enable`.
43+
2. Update the following NuGet packages to `6.0.0` or later:
44+
- Microsoft.EntityFrameworkCore.Design
45+
- Microsoft.EntityFrameworkCore.SqlServer
46+
- EntityFrameworkCore.Scaffolding.Handlebars
47+
3. Remove the `EnableNullableReferenceTypes` option from `services.AddHandlebarsScaffolding` in `ScaffoldingDesignTimeServices.ConfigureDesignTimeServices`.
48+
- Version 6 relies on [support for nullable reference types in EF Core 6](https://docs.microsoft.com/en-us/ef/core/miscellaneous/nullable-reference-types).
49+
4. Run `dotnet ef dbcontext scaffold` command to regenerate entities.
50+
- You may retain your customized Handlebars templates.
51+
- [Many-to-many relationships](https://docs.microsoft.com/en-us/ef/core/modeling/relationships?tabs=fluent-api%2Cfluent-api-simple-key%2Csimple-key#many-to-many) will be materialized without the need for an intermediate entity.
52+
3853
## Usage
3954
4055
1. Create a new **.NET 6** class library.
@@ -94,8 +109,7 @@ Take advantage of C# nullable reference types by enabling them in your .csproj f
94109
95110
```xml
96111
<PropertyGroup>
97-
<TargetFramework>netcoreapp3.1</TargetFramework>
98-
<LangVersion>8.0</LangVersion>
112+
<TargetFramework>net6.0</TargetFramework>
99113
<Nullable>enable</Nullable>
100114
</PropertyGroup>
101115
```
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
public {{class}}(DbContextOptions<{{class}}> options) : base(options)
2+
{
3+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Microsoft.EntityFrameworkCore;
4+
using Microsoft.EntityFrameworkCore.Metadata;
5+
{{#if model-namespace}}
6+
using {{model-namespace}};
7+
{{/if}}
8+
{{#each model-imports}}
9+
using {{model-import}};
10+
{{/each}}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
2+
{
3+
if (!optionsBuilder.IsConfigured)
4+
{
5+
{{#if connectionstring-warning}}
6+
{{connectionstring-warning}}
7+
{{/if}}
8+
optionsBuilder{{options-builder-provider}};
9+
}
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{{#each dbsets}}
2+
public virtual DbSet<{{set-property-type}}> {{set-property-name}} { get; set; }{{#if nullable-reference-types }} = default!;{{/if}}
3+
{{/each}}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,4 @@
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}}
2617
{{/if}}
Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
import { Product } from './Product';
22

3-
/**
4-
* hello table Customer
5-
*/
63
export interface Category {
74
categoryId: number;
8-
/**
9-
* hello CompanyName
10-
*/
115
categoryName: string;
126
products: Product[];
137
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EmployeeTerritory } from './EmployeeTerritory';
1+
import { Territory } from './Territory';
22

33
export interface Employee {
44
employeeId: number;
@@ -8,5 +8,5 @@ export interface Employee {
88
hireDate: Date;
99
city: string;
1010
country: string;
11-
employeeTerritories: EmployeeTerritory[];
11+
territories: Territory[];
1212
}
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
import { Employee } from './Employee';
2-
import { Territory } from './Territory';
3-
1+

42
export interface EmployeeTerritory {
53
employeeId: number;
64
territoryId: string;
7-
employee: Employee;
8-
territory: Territory;
95
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { EmployeeTerritory } from './EmployeeTerritory';
1+
import { Employee } from './Employee';
22

33
export interface Territory {
44
territoryId: string;
55
territoryDescription: string;
6-
employeeTerritories: EmployeeTerritory[];
6+
employees: Employee[];
77
}

0 commit comments

Comments
 (0)