Skip to content

Commit 2ddd977

Browse files
authored
Merge pull request #220 from TrackableEntities/update-ef7
Upgrade to EF Core 7
2 parents 2b65b77 + 72f03eb commit 2ddd977

File tree

58 files changed

+272
-319
lines changed

Some content is hidden

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

58 files changed

+272
-319
lines changed

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Trackable Entities
3+
Copyright (c) 2022 Trackable Entities
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ 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, [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.
19-
- [EF Core CLI 6.0](https://docs.microsoft.com/en-us/ef/core/cli/dotnet) or greater.
17+
- [Visual Studio 2022](https://www.visualstudio.com/downloads/) or greater, [JetBrains Rider](https://www.jetbrains.com/rider) 2022.2 or greater.
18+
- [.NET 7.0 SDK](https://dotnet.microsoft.com/download/dotnet/7.0) or greater.
19+
- [EF Core CLI 7.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
@@ -35,24 +35,24 @@ 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
38+
## Upgrading
3939
40-
1. Upgrade `TargetFramework` in **.csproj** file to `net6.0`.
40+
1. Upgrade `TargetFramework` in **.csproj** file to `net6.0` or `net7.0`.
4141
- Optional: Set `ImplicitUsings` to `enable`.
4242
- Optional: Set `Nullable` ro `enable`.
43-
2. Update the following NuGet packages to `6.0.0` or later:
43+
2. Update the following NuGet packages to `7.0.0` or later:
4444
- Microsoft.EntityFrameworkCore.Design
4545
- Microsoft.EntityFrameworkCore.SqlServer
4646
- EntityFrameworkCore.Scaffolding.Handlebars
4747
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).
48+
- Version 6 or greater relies on [support for nullable reference types in EF Core 6](https://docs.microsoft.com/en-us/ef/core/miscellaneous/nullable-reference-types).
4949
4. Run `dotnet ef dbcontext scaffold` command to regenerate entities.
5050
- You may retain your customized Handlebars templates.
5151
- [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.
5252
5353
## Usage
5454
55-
1. Create a new **.NET 6** class library.
55+
1. Create a new **.NET 6** or **.NET 7** class library.
5656
5757
2. Add EF Core SQL Server and Tools NuGet packages.
5858
- `Microsoft.EntityFrameworkCore.SqlServer`
@@ -105,7 +105,7 @@ Before creating a pull request, please refer to the [Contributing Guidelines](ht
105105
106106
## Nullable Reference Types
107107
108-
Take advantage of C# nullable reference types by enabling them in your .csproj file. (This is by default in .NET 6.)
108+
Take advantage of C# nullable reference types by enabling them in your .csproj file. (This is by default in .NET 6 or greater.)
109109
110110
```xml
111111
<PropertyGroup>

sample/ScaffoldingSample.Api/ScaffoldingSample.Api.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

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

1212
<ItemGroup>

sample/ScaffoldingSample.Embedded/Contexts/NorthwindSlimContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
3636
{
3737
entity.ToTable("Category");
3838

39-
entity.HasComment("hello table Customer");
39+
entity.HasAnnotation("Relational: Comment", "A category of products");
4040

4141
entity.Property(e => e.CategoryName)
4242
.IsRequired()

sample/ScaffoldingSample.Embedded/ScaffoldingSample.Embedded.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
11-
<PrivateAssets>all</PrivateAssets>
12-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
1414
</ItemGroup>
1515

sample/ScaffoldingSample.TypeScript/ScaffoldingSample.TypeScript.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
11-
<PrivateAssets>all</PrivateAssets>
12-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1313
</PackageReference>
1414
</ItemGroup>
1515

sample/ScaffoldingSample/CodeTemplates/CSharpDbContext/DbContext.hbs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ namespace {{namespace}}
55
public partial class {{class}} : DbContext
66
{
77
{{{> dbsets}}}
8-
{{#if entity-type-errors}}
9-
{{#each entity-type-errors}}
10-
{{{entity-type-error}}}
11-
{{/each}}
12-
13-
{{/if}}
148

159
{{{> dbconstructor}}}
1610

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
public {{class}}(DbContextOptions<{{class}}> options) : base(options)
1+
public {{class}}()
2+
{
3+
}
4+
5+
public {{class}}(DbContextOptions<{{class}}> options) : base(options)
26
{
37
}

sample/ScaffoldingSample/Contexts/NorthwindSlimContext.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ public partial class NorthwindSlimContext : DbContext
2525
// My Handlebars Helper
2626
public virtual DbSet<dbo.Territory> Territories { get; set; } = null!;
2727

28+
public NorthwindSlimContext()
29+
{
30+
}
31+
2832
public NorthwindSlimContext(DbContextOptions<NorthwindSlimContext> options) : base(options)
2933
{
3034
}

sample/ScaffoldingSample/Sample.ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Demonstrates how to reverse engineer an existing database using the EF Core tool
44

55
## Prerequisites
66

7-
- [Visual Studio 2019](https://www.visualstudio.com/downloads/) 16.4 or greater.
8-
- The .[NET Core 3.1 SDK](https://www.microsoft.com/net/download/core).
7+
- [Visual Studio 2022](https://www.visualstudio.com/downloads/) 17.4 or greater.
8+
- The .[NET SDK](https://www.microsoft.com/net/download/core).
99

1010
## Database Setup
1111

sample/ScaffoldingSample/ScaffoldingSample.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.1" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.1">
12-
<PrivateAssets>all</PrivateAssets>
13-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0">
12+
<PrivateAssets>all</PrivateAssets>
13+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
</PackageReference>
1515
</ItemGroup>
1616

sample/TemplatesAssembly/CodeTemplates/CSharpDbContext/DbContext.hbs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ namespace {{namespace}}
55
public partial class {{class}} : DbContext
66
{
77
{{{> dbsets}}}
8-
{{#if entity-type-errors}}
9-
{{#each entity-type-errors}}
10-
{{{entity-type-error}}}
11-
{{/each}}
12-
13-
{{/if}}
148

159
{{{> dbconstructor}}}
1610

sample/TemplatesAssembly/CodeTemplates/TypeScriptDbContext/DbContext.hbs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ namespace {{namespace}}
55
public partial class {{class}} : DbContext
66
{
77
{{{> dbsets}}}
8-
{{#if entity-type-errors}}
9-
{{#each entity-type-errors}}
10-
{{{entity-type-error}}}
11-
{{/each}}
12-
13-
{{/if}}
148

159
{{{> dbconstructor}}}
1610

src/EntityFrameworkCore.Scaffolding.Handlebars/CodeTemplates/CSharpDbContext/DbContext.hbs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ namespace {{namespace}}
55
public partial class {{class}} : DbContext
66
{
77
{{{> dbsets}}}
8-
{{#if entity-type-errors}}
9-
{{#each entity-type-errors}}
10-
{{{entity-type-error}}}
11-
{{/each}}
12-
13-
{{/if}}
148

159
{{{> dbconstructor}}}
1610

Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1-
public {{class}}(DbContextOptions<{{class}}> options) : base(options)
1+
public {{class}}()
2+
{
3+
}
4+
5+
public {{class}}(DbContextOptions<{{class}}> options) : base(options)
26
{
37
}

src/EntityFrameworkCore.Scaffolding.Handlebars/CodeTemplates/TypeScriptDbContext/DbContext.hbs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,6 @@ namespace {{namespace}}
55
public partial class {{class}} : DbContext
66
{
77
{{{> dbsets}}}
8-
{{#if entity-type-errors}}
9-
{{#each entity-type-errors}}
10-
{{{entity-type-error}}}
11-
{{/each}}
12-
13-
{{/if}}
148

159
{{{> dbconstructor}}}
1610

src/EntityFrameworkCore.Scaffolding.Handlebars/EntityFrameworkCore.Scaffolding.Handlebars.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
55
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
6-
<Version>6.0.3</Version>
6+
<Version>7.0.0-beta1</Version>
77
<Authors>Tony Sneed</Authors>
88
<Company>Tony Sneed</Company>
99
<Title>Entity Framework Core Scaffolding with Handlebars</Title>
@@ -17,8 +17,8 @@
1717
<IncludeSource>true</IncludeSource>
1818
<SignAssembly>true</SignAssembly>
1919
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
20-
<AssemblyVersion>6.0.0.0</AssemblyVersion>
21-
<FileVersion>6.0.0.0</FileVersion>
20+
<AssemblyVersion>7.0.0.0</AssemblyVersion>
21+
<FileVersion>7.0.0.0</FileVersion>
2222
<GenerateDocumentationFile>True</GenerateDocumentationFile>
2323
</PropertyGroup>
2424

@@ -27,10 +27,10 @@
2727
</ItemGroup>
2828

2929
<ItemGroup>
30-
<PackageReference Include="Handlebars.Net" Version="2.0.10" />
31-
<PackageReference Include="JetBrains.Annotations" Version="2021.3.0" />
32-
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="6.0.0" />
33-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0" />
30+
<PackageReference Include="Handlebars.Net" Version="2.1.2" />
31+
<PackageReference Include="JetBrains.Annotations" Version="2022.3.1" />
32+
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="7.0.0" />
33+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0" />
3434
</ItemGroup>
3535

3636
<ItemGroup>

src/EntityFrameworkCore.Scaffolding.Handlebars/HandlebarsScaffoldingOptions.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
2-
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
3-
4-
// Modifications copyright(C) 2019 Tony Sneed.
5-
6-
using System;
1+
using System;
72
using System.Collections.Generic;
83
using System.Reflection;
94
using Microsoft.EntityFrameworkCore.Design;

0 commit comments

Comments
 (0)