Skip to content

Commit 1b6047b

Browse files
committed
upgrade to Core 2.2
1 parent bddc83b commit 1b6047b

File tree

83 files changed

+27406
-11300
lines changed

Some content is hidden

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

83 files changed

+27406
-11300
lines changed

.bowerrc

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

Controllers/HomeController.cs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Diagnostics;
34
using System.Linq;
45
using System.Threading.Tasks;
56
using Microsoft.AspNetCore.Mvc;
7+
using DotNetCoreSqlDb.Models;
68

79
namespace DotNetCoreSqlDb.Controllers
810
{
@@ -13,23 +15,15 @@ public IActionResult Index()
1315
return View();
1416
}
1517

16-
public IActionResult About()
18+
public IActionResult Privacy()
1719
{
18-
ViewData["Message"] = "Your application description page.";
19-
20-
return View();
21-
}
22-
23-
public IActionResult Contact()
24-
{
25-
ViewData["Message"] = "Your contact page.";
26-
2720
return View();
2821
}
2922

23+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
3024
public IActionResult Error()
3125
{
32-
return View();
26+
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
3327
}
3428
}
3529
}

Controllers/TodoesController.cs renamed to Controllers/TodosController.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
@@ -15,7 +15,7 @@ public class TodosController : Controller
1515

1616
public TodosController(MyDatabaseContext context)
1717
{
18-
_context = context;
18+
_context = context;
1919
}
2020

2121
// GET: Todos
@@ -33,7 +33,7 @@ public async Task<IActionResult> Details(int? id)
3333
}
3434

3535
var todo = await _context.Todo
36-
.SingleOrDefaultAsync(m => m.ID == id);
36+
.FirstOrDefaultAsync(m => m.ID == id);
3737
if (todo == null)
3838
{
3939
return NotFound();
@@ -59,7 +59,7 @@ public async Task<IActionResult> Create([Bind("ID,Description,CreatedDate")] Tod
5959
{
6060
_context.Add(todo);
6161
await _context.SaveChangesAsync();
62-
return RedirectToAction("Index");
62+
return RedirectToAction(nameof(Index));
6363
}
6464
return View(todo);
6565
}
@@ -72,7 +72,7 @@ public async Task<IActionResult> Edit(int? id)
7272
return NotFound();
7373
}
7474

75-
var todo = await _context.Todo.SingleOrDefaultAsync(m => m.ID == id);
75+
var todo = await _context.Todo.FindAsync(id);
7676
if (todo == null)
7777
{
7878
return NotFound();
@@ -110,7 +110,7 @@ public async Task<IActionResult> Edit(int id, [Bind("ID,Description,CreatedDate"
110110
throw;
111111
}
112112
}
113-
return RedirectToAction("Index");
113+
return RedirectToAction(nameof(Index));
114114
}
115115
return View(todo);
116116
}
@@ -124,7 +124,7 @@ public async Task<IActionResult> Delete(int? id)
124124
}
125125

126126
var todo = await _context.Todo
127-
.SingleOrDefaultAsync(m => m.ID == id);
127+
.FirstOrDefaultAsync(m => m.ID == id);
128128
if (todo == null)
129129
{
130130
return NotFound();
@@ -138,10 +138,10 @@ public async Task<IActionResult> Delete(int? id)
138138
[ValidateAntiForgeryToken]
139139
public async Task<IActionResult> DeleteConfirmed(int id)
140140
{
141-
var todo = await _context.Todo.SingleOrDefaultAsync(m => m.ID == id);
141+
var todo = await _context.Todo.FindAsync(id);
142142
_context.Todo.Remove(todo);
143143
await _context.SaveChangesAsync();
144-
return RedirectToAction("Index");
144+
return RedirectToAction(nameof(Index));
145145
}
146146

147147
private bool TodoExists(int id)

DotNetCoreSqlDb.csproj

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

33
<PropertyGroup>
4-
<TargetFramework>netcoreapp2.1</TargetFramework>
4+
<TargetFramework>netcoreapp2.2</TargetFramework>
5+
<AspNetCoreHostingModel>InProcess</AspNetCoreHostingModel>
56
</PropertyGroup>
67

7-
<ItemGroup>
8-
<PackageReference Include="Microsoft.AspNetCore" Version="2.1.7" />
9-
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.1.3" />
10-
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.1.1" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.1.4" />
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.4" />
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.1.4" />
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.Design" Version="1.1.6" />
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.4" />
16-
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.1.1" />
17-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
18-
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="2.1.1" />
19-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.1.7" />
20-
</ItemGroup>
218

229
<ItemGroup>
23-
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
10+
<PackageReference Include="Microsoft.AspNetCore.App" />
11+
<PackageReference Include="Microsoft.AspNetCore.Razor.Design" Version="2.2.0" PrivateAssets="All" />
12+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.6" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.2.6" />
14+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.2.3" />
2415
</ItemGroup>
2516

2617
</Project>

Migrations/20170901142627_Initial.Designer.cs

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

Migrations/20170901142627_Initial.cs

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

Migrations/MyDatabaseContextModelSnapshot.cs

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

Models/ErrorViewModel.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
3+
namespace DotNetCoreSqlDb.Models
4+
{
5+
public class ErrorViewModel
6+
{
7+
public string RequestId { get; set; }
8+
9+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
10+
}
11+
}

Models/Todo.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ public class Todo
1717
public DateTime CreatedDate { get; set; }
1818
}
1919
}
20+

Program.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,20 @@
55
using System.Threading.Tasks;
66
using Microsoft.AspNetCore;
77
using Microsoft.AspNetCore.Hosting;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.Logging;
810

911
namespace DotNetCoreSqlDb
1012
{
1113
public class Program
1214
{
1315
public static void Main(string[] args)
1416
{
15-
BuildWebHost(args).Run();
17+
CreateWebHostBuilder(args).Build().Run();
1618
}
1719

18-
public static IWebHost BuildWebHost(string[] args) =>
20+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
1921
WebHost.CreateDefaultBuilder(args)
20-
.UseStartup<Startup>()
21-
.Build();
22+
.UseStartup<Startup>();
2223
}
2324
}

0 commit comments

Comments
 (0)