Skip to content

Commit 5d0c21a

Browse files
authored
Merge pull request #235 from TrackableEntities/update-net-8
Upgrade to .NET 8.0
2 parents 0bd6c73 + 3a35b17 commit 5d0c21a

Some content is hidden

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

44 files changed

+488
-559
lines changed

EntityFrameworkCore.Scaffolding.Handlebars.sln

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sample", "sample", "{B16E9B
2121
EndProject
2222
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScaffoldingSample", "sample\ScaffoldingSample\ScaffoldingSample.csproj", "{02EC28F3-AA15-4429-9D49-6CE1F2ACCEFA}"
2323
EndProject
24-
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScaffoldingSample.Api", "sample\ScaffoldingSample.Api\ScaffoldingSample.Api.csproj", "{6141959E-72B2-4FA5-AE75-E0053BFE16D1}"
25-
EndProject
2624
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScaffoldingSample.TypeScript", "sample\ScaffoldingSample.TypeScript\ScaffoldingSample.TypeScript.csproj", "{2713D6F6-6ADE-4E3F-8D07-30E19C14AD68}"
2725
EndProject
2826
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TemplatesAssembly", "sample\TemplatesAssembly\TemplatesAssembly.csproj", "{BA4575F5-1DDF-4E7D-A06E-09E56703C3FA}"
2927
EndProject
3028
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScaffoldingSample.Embedded", "sample\ScaffoldingSample.Embedded\ScaffoldingSample.Embedded.csproj", "{9288FD98-43FC-4E6B-87FC-FC43E8071C07}"
3129
EndProject
30+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScaffoldingSample.Api", "sample\ScaffoldingSample.Api\ScaffoldingSample.Api.csproj", "{6D11B09D-28D2-47F5-B49B-4493C3051EF1}"
31+
EndProject
3232
Global
3333
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3434
Debug|Any CPU = Debug|Any CPU
@@ -47,10 +47,6 @@ Global
4747
{02EC28F3-AA15-4429-9D49-6CE1F2ACCEFA}.Debug|Any CPU.Build.0 = Debug|Any CPU
4848
{02EC28F3-AA15-4429-9D49-6CE1F2ACCEFA}.Release|Any CPU.ActiveCfg = Release|Any CPU
4949
{02EC28F3-AA15-4429-9D49-6CE1F2ACCEFA}.Release|Any CPU.Build.0 = Release|Any CPU
50-
{6141959E-72B2-4FA5-AE75-E0053BFE16D1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51-
{6141959E-72B2-4FA5-AE75-E0053BFE16D1}.Debug|Any CPU.Build.0 = Debug|Any CPU
52-
{6141959E-72B2-4FA5-AE75-E0053BFE16D1}.Release|Any CPU.ActiveCfg = Release|Any CPU
53-
{6141959E-72B2-4FA5-AE75-E0053BFE16D1}.Release|Any CPU.Build.0 = Release|Any CPU
5450
{2713D6F6-6ADE-4E3F-8D07-30E19C14AD68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
5551
{2713D6F6-6ADE-4E3F-8D07-30E19C14AD68}.Debug|Any CPU.Build.0 = Debug|Any CPU
5652
{2713D6F6-6ADE-4E3F-8D07-30E19C14AD68}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -63,6 +59,10 @@ Global
6359
{9288FD98-43FC-4E6B-87FC-FC43E8071C07}.Debug|Any CPU.Build.0 = Debug|Any CPU
6460
{9288FD98-43FC-4E6B-87FC-FC43E8071C07}.Release|Any CPU.ActiveCfg = Release|Any CPU
6561
{9288FD98-43FC-4E6B-87FC-FC43E8071C07}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{6D11B09D-28D2-47F5-B49B-4493C3051EF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{6D11B09D-28D2-47F5-B49B-4493C3051EF1}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{6D11B09D-28D2-47F5-B49B-4493C3051EF1}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{6D11B09D-28D2-47F5-B49B-4493C3051EF1}.Release|Any CPU.Build.0 = Release|Any CPU
6666
EndGlobalSection
6767
GlobalSection(SolutionProperties) = preSolution
6868
HideSolutionNode = FALSE
@@ -71,10 +71,10 @@ Global
7171
{C8D8B5AB-0F65-4C22-AC7A-BB1350043757} = {CE438F3D-E03D-4DF5-A4A1-6FA57576F9A4}
7272
{CF5E7978-FC4B-4620-8CDF-EA622B6159C0} = {0C310C69-DDCB-4A47-A286-601C74BE5D96}
7373
{02EC28F3-AA15-4429-9D49-6CE1F2ACCEFA} = {B16E9B06-FE29-413E-B98F-6123DCB92394}
74-
{6141959E-72B2-4FA5-AE75-E0053BFE16D1} = {B16E9B06-FE29-413E-B98F-6123DCB92394}
7574
{2713D6F6-6ADE-4E3F-8D07-30E19C14AD68} = {B16E9B06-FE29-413E-B98F-6123DCB92394}
7675
{BA4575F5-1DDF-4E7D-A06E-09E56703C3FA} = {B16E9B06-FE29-413E-B98F-6123DCB92394}
7776
{9288FD98-43FC-4E6B-87FC-FC43E8071C07} = {B16E9B06-FE29-413E-B98F-6123DCB92394}
77+
{6D11B09D-28D2-47F5-B49B-4493C3051EF1} = {B16E9B06-FE29-413E-B98F-6123DCB92394}
7878
EndGlobalSection
7979
GlobalSection(ExtensibilityGlobals) = postSolution
8080
SolutionGuid = {15011E43-4689-4DD6-A1F4-C388E5012B58}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Before creating a pull request, please refer to the [Contributing Guidelines](ht
1515
## Prerequisites
1616

1717
- [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.
18+
- [.NET 8.0 SDK](https://dotnet.microsoft.com/download/dotnet) or greater.
19+
- [EF Core CLI 8.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
@@ -37,10 +37,10 @@ Before creating a pull request, please refer to the [Contributing Guidelines](ht
3737
3838
## Upgrading
3939
40-
1. Upgrade `TargetFramework` in **.csproj** file to `net6.0` or `net7.0`.
40+
1. Upgrade `TargetFramework` in **.csproj** file to `net8.0`.
4141
- Optional: Set `ImplicitUsings` to `enable`.
4242
- Optional: Set `Nullable` ro `enable`.
43-
2. Update the following NuGet packages to `7.0.0` or later:
43+
2. Update the following NuGet packages to `8.0.0` or later:
4444
- Microsoft.EntityFrameworkCore.Design
4545
- Microsoft.EntityFrameworkCore.SqlServer
4646
- EntityFrameworkCore.Scaffolding.Handlebars
@@ -52,7 +52,7 @@ Before creating a pull request, please refer to the [Contributing Guidelines](ht
5252
5353
## Usage
5454
55-
1. Create a new **.NET 6** or **.NET 7** class library.
55+
1. Create a new **.NET 8** class library.
5656
5757
2. Add EF Core SQL Server and Tools NuGet packages.
5858
- `Microsoft.EntityFrameworkCore.SqlServer`

global.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"sdk": {
3+
"version": "8.0.0",
4+
"rollForward": "latestMajor",
5+
"allowPrerelease": true
6+
}
7+
}
Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,29 @@
1-
using System.Linq;
2-
using System.Threading.Tasks;
31
using Microsoft.AspNetCore.Mvc;
42
using Microsoft.EntityFrameworkCore;
53
using ScaffoldingSample.Contexts;
64

7-
namespace ScaffoldingSample.Api.Controllers
5+
namespace ScaffoldingSample.Api.Controllers;
6+
7+
[Route("api/[controller]")]
8+
[ApiController]
9+
public class EmployeeController(NorthwindSlimContext context) : ControllerBase
810
{
9-
[Route("api/[controller]")]
10-
[ApiController]
11-
public class EmployeeController : ControllerBase
11+
// GET api/employee
12+
[HttpGet]
13+
public async Task<ActionResult> Get()
1214
{
13-
private readonly NorthwindSlimContext _context;
14-
15-
public EmployeeController(NorthwindSlimContext context)
16-
{
17-
_context = context;
18-
}
19-
20-
// GET api/employee
21-
[HttpGet]
22-
public async Task<ActionResult> Get()
23-
{
24-
var employees = await _context.Employees
25-
.OrderBy(e => e.LastName).ThenBy(e => e.FirstName)
26-
.Select(e => new
27-
{
28-
e.EmployeeId,
29-
e.LastName,
30-
e.FirstName,
31-
BirthDate = e.BirthDate.GetValueOrDefault().ToShortDateString(),
32-
HireDate = e.HireDate.GetValueOrDefault().ToShortDateString(),
33-
Country = e.Country.ToString()
34-
})
35-
.ToListAsync();
36-
return Ok(employees);
37-
}
15+
var employees = await context.Employees
16+
.OrderBy(e => e.LastName).ThenBy(e => e.FirstName)
17+
.Select(e => new
18+
{
19+
e.EmployeeId,
20+
e.LastName,
21+
e.FirstName,
22+
BirthDate = e.BirthDate.GetValueOrDefault().ToShortDateString(),
23+
HireDate = e.HireDate.GetValueOrDefault().ToShortDateString(),
24+
e.Country
25+
})
26+
.ToListAsync();
27+
return Ok(employees);
3828
}
39-
}
29+
}
Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,30 @@
1-
using Microsoft.AspNetCore.Hosting;
2-
using Microsoft.Extensions.Hosting;
1+
using Microsoft.EntityFrameworkCore;
2+
using ScaffoldingSample.Contexts;
33

4-
namespace ScaffoldingSample.Api
4+
var builder = WebApplication.CreateBuilder(args);
5+
6+
// Add services to the container.
7+
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
8+
builder.Services.AddEndpointsApiExplorer();
9+
builder.Services.AddSwaggerGen();
10+
builder.Services.AddControllers();
11+
builder.Services.AddDbContext<NorthwindSlimContext>(options =>
512
{
6-
public class Program
7-
{
8-
public static void Main(string[] args)
9-
{
10-
CreateHostBuilder(args).Build().Run();
11-
}
13+
var connectionString = builder.Configuration.GetConnectionString(nameof(NorthwindSlimContext));
14+
options.UseSqlServer(connectionString);
15+
});
16+
17+
var app = builder.Build();
1218

13-
public static IHostBuilder CreateHostBuilder(string[] args) =>
14-
Host.CreateDefaultBuilder(args)
15-
.ConfigureWebHostDefaults(webBuilder =>
16-
{
17-
webBuilder.UseStartup<Startup>();
18-
});
19-
}
19+
// Configure the HTTP request pipeline.
20+
if (app.Environment.IsDevelopment())
21+
{
22+
app.UseSwagger();
23+
app.UseSwaggerUI();
2024
}
25+
26+
app.UseHttpsRedirection();
27+
28+
app.MapControllers();
29+
30+
app.Run();
Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
{
22
"$schema": "http://json.schemastore.org/launchsettings.json",
3-
"iisSettings": {
4-
"windowsAuthentication": false,
5-
"anonymousAuthentication": true,
6-
"iisExpress": {
7-
"applicationUrl": "http://localhost:49638",
8-
"sslPort": 0
9-
}
10-
},
113
"profiles": {
12-
"IIS Express": {
13-
"commandName": "IISExpress",
4+
"http": {
5+
"commandName": "Project",
6+
"dotnetRunMessages": true,
147
"launchBrowser": true,
15-
"launchUrl": "api/employee",
8+
"launchUrl": "swagger",
9+
"applicationUrl": "http://localhost:5041",
1610
"environmentVariables": {
1711
"ASPNETCORE_ENVIRONMENT": "Development"
1812
}
1913
},
20-
"ScaffoldingSample.Api": {
14+
"https": {
2115
"commandName": "Project",
16+
"dotnetRunMessages": true,
2217
"launchBrowser": true,
23-
"launchUrl": "api/employee",
24-
"applicationUrl": "http://localhost:5000",
18+
"launchUrl": "swagger",
19+
"applicationUrl": "https://localhost:7208;http://localhost:5041",
2520
"environmentVariables": {
2621
"ASPNETCORE_ENVIRONMENT": "Development"
2722
}
2823
}
2924
}
30-
}
25+
}

sample/ScaffoldingSample.Api/ScaffoldingSample.Api.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>net6.0</TargetFramework>
5-
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
4+
<TargetFramework>net8.0</TargetFramework>
5+
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<InvariantGlobalization>false</InvariantGlobalization>
8+
<UserSecretsId>12811259-bfae-451f-9a72-050791c4ed4b</UserSecretsId>
69
</PropertyGroup>
710

811
<ItemGroup>
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.0" />
12+
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
13+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.0" />
14+
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" />
15+
</ItemGroup>
16+
17+
<ItemGroup>
18+
<Folder Include="Controllers\" />
1019
</ItemGroup>
1120

1221
<ItemGroup>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
@SaffoldingSample.Api_HostAddress = http://localhost:5041
2+
3+
GET {{SaffoldingSample.Api_HostAddress}}/weatherforecast/
4+
Accept: application/json
5+
6+
###
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScaffoldingSample.Api", "ScaffoldingSample.Api.csproj", "{E841BA04-0CB7-46A9-8CE5-02049F3A499C}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{E841BA04-0CB7-46A9-8CE5-02049F3A499C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{E841BA04-0CB7-46A9-8CE5-02049F3A499C}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{E841BA04-0CB7-46A9-8CE5-02049F3A499C}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{E841BA04-0CB7-46A9-8CE5-02049F3A499C}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {DB5CBEB7-A02F-48C9-BD88-FC41367DDFB2}
24+
EndGlobalSection
25+
EndGlobal

sample/ScaffoldingSample.Api/Startup.cs

Lines changed: 0 additions & 51 deletions
This file was deleted.

0 commit comments

Comments
 (0)