Skip to content

Commit

Permalink
Got rid off DateOnly converters
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Klaus committed Jan 1, 2024
1 parent 8dfb694 commit 66b9dea
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 68 deletions.
4 changes: 3 additions & 1 deletion Api/Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

<ItemGroup>
<PackageReference Include="DomainResult" Version="3.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<!-- The EF references below are required for generating the migration script only -->
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0" />
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 1 addition & 3 deletions Database/DataContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AK.DbSample.Database.Entities;
using AK.DbSample.Database.Infrastructure;

using Microsoft.EntityFrameworkCore;

Expand All @@ -20,8 +19,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
// Date is a DateOnly property and date on database
builder.Property(x => x.Date)
// These converters are still required in EF 7 (https://github.com/dotnet/efcore/issues/24507)
.HasConversion<DateOnlyConverter, DateOnlyComparer>();
.HasColumnType("date");

// Set cascade delete
builder.HasOne(p => p.Client)
Expand Down
29 changes: 0 additions & 29 deletions Database/Infrastructure/DateOnlyComparer.cs

This file was deleted.

34 changes: 0 additions & 34 deletions Database/Infrastructure/DateOnlyConverter.cs

This file was deleted.

2 changes: 1 addition & 1 deletion Database/Migrations/20220322114144_InititalCreate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override void Up(MigrationBuilder migrationBuilder)
{
Number = table.Column<string>(type: "nvarchar(100)", nullable: false),
ClientId = table.Column<long>(type: "bigint", nullable: false),
Date = table.Column<DateTime>(type: "datetime", nullable: false),
Date = table.Column<DateOnly>(type: "date", nullable: false),
Amount = table.Column<decimal>(type: "decimal(18,2)", nullable: false)
},
constraints: table =>
Expand Down

0 comments on commit 66b9dea

Please sign in to comment.