Skip to content

Commit

Permalink
migration to dotnet8 for efcore feature
Browse files Browse the repository at this point in the history
  • Loading branch information
godunko-mikhail committed Mar 26, 2023
1 parent 09c6fc0 commit 0dff42b
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Application.Tests/Application.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

Expand Down
2 changes: 1 addition & 1 deletion WebGP.Application/WebGP.Application.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion WebGP.Domain/WebGP.Domain.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
39 changes: 38 additions & 1 deletion WebGP.Infrastructure/DataBase/ApplicationDbContext.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using Microsoft.EntityFrameworkCore;
using WebGP.Application.Common.Interfaces;
using WebGP.Application.Common.VM;
using WebGP.Domain.Entities;

namespace WebGP.Infrastructure.DataBase;
Expand Down Expand Up @@ -312,8 +313,44 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
entity.Property(e => e.Name)
.HasColumnType("text")
.HasColumnName("name");
});
});
/*modelBuilder.Entity<OnlineVm>(entity =>
{
entity.HasNoKey();
entity.Property(e => e.TimedId)
.HasColumnName("timed_id")
.HasColumnType("int(11)");
entity.Property(e => e.Uuid)
.HasColumnName("uuid")
.HasMaxLength(36);
entity.Property(e => e.StaticId)
.HasColumnName("id")
.HasColumnType("int(11)");
entity.Property(e => e.FirstName)
.HasColumnName("first_name")
.HasMaxLength(15);
entity.Property(e => e.LastName)
.HasColumnName("last_name")
.HasMaxLength(15);
entity.Property(e => e.DiscordId)
.HasColumnName("discord_id")
.HasColumnType("bigint(20)");
entity.Property(e => e.Role)
.HasColumnName("role")
.HasColumnType("mediumtext")
.UseCollation("utf8mb4_unicode_ci");
entity.Property(e => e.Work)
.HasColumnName("work")
.HasColumnType("mediumtext")
.UseCollation("utf8mb4_unicode_ci");
entity.Property(e => e.Level)
.HasColumnName("Level")
.HasColumnType("int(11)");
entity.Property(e => e.SkinUrl)
.HasColumnName("skin_url")
.HasColumnType("text");
});*/
OnModelCreatingPartial(modelBuilder);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,8 @@ protected override void Up(MigrationBuilder migrationBuilder)
// creating view
migrationBuilder.Sql("CREATE ALGORITHM=UNDEFINED SQL SECURITY DEFINER VIEW `role_work_readonly` AS select `work_readonly`.`id` AS `id`,`work_readonly`.`type` AS `type`,`work_readonly`.`icon` AS `icon`,`work_readonly`.`name` AS `name` from `work_readonly` union select `roles`.`id` AS `id`,'ROLE' AS `type`,if(octet_length(`roles`.`name`) = 0,'',concat('<#',`roles`.`color`,'>',`roles`.`name`)) AS `icon`,`roles`.`name` AS `name` from `roles`;");
migrationBuilder.Sql(
"DELIMITER //\r\nCREATE FUNCTION `GetLevel`(`_exp` INT\r\n) RETURNS int(11)\r\nBEGIN\r\n DECLARE _level INT DEFAULT 0;\r\n DECLARE _next INT DEFAULT 0;\r\n WHILE (TRUE) DO\r\n SET _next = _next + _level * 4;\r\n IF (_exp < _next) THEN\r\n RETURN _level - 1;\r\n END IF;\r\n SET _level = _level + 1;\r\n END WHILE;\r\nEND//\r\nDELIMITER ;");
migrationBuilder.Sql("DELIMITER //\r\nCREATE FUNCTION `GetExp`(`_level` INT\r\n) RETURNS int(11)\r\nBEGIN\r\n DECLARE _next INT DEFAULT 0;\r\n WHILE (TRUE) DO\r\n SET _next = _next + _level * 4;\r\n IF (_level = 0) THEN\r\n RETURN _next;\r\n END IF;\r\n SET _level = _level - 1;\r\n END WHILE;\r\nEND//\r\nDELIMITER ;");
"CREATE FUNCTION `GetLevel`(`_exp` INT) RETURNS int(11)BEGIN DECLARE _level INT DEFAULT 0; DECLARE _next INT DEFAULT 0; WHILE (TRUE) DO SET _next = _next + _level * 4; IF (_exp < _next) THEN RETURN _level - 1; END IF; SET _level = _level + 1; END WHILE;END");
migrationBuilder.Sql("CREATE FUNCTION `GetExp`(`_level` INT) RETURNS int(11)BEGIN DECLARE _next INT DEFAULT 0; WHILE (TRUE) DO SET _next = _next + _level * 4; IF (_level = 0) THEN RETURN _next; END IF; SET _level = _level - 1; END WHILE;END");
}

/// <inheritdoc />
Expand Down
2 changes: 1 addition & 1 deletion WebGP.Infrastructure/DataBase/OnlineRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class OnlineRepository : IOnlineRepository
SELECT
online.timed_id AS 'TimedId',
online.`uuid` AS 'Uuid',
users.id AS 'Id',
users.id AS 'StaticId',
users.first_name AS 'FirstName',
users.last_name AS 'LastName',
discord.discord_id AS 'DiscordId',
Expand Down
5 changes: 3 additions & 2 deletions WebGP.Infrastructure/WebGP.Infrastructure.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Dapper" Version="2.0.123" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0-preview.2.23128.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="8.0.0-preview.2.23128.3" />
<PackageReference Include="Microsoft.IdentityModel.Tokens" Version="6.27.0" />
<PackageReference Include="MySql.Data" Version="8.0.32.1" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
Expand Down
4 changes: 2 additions & 2 deletions WebGP/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
FROM mcr.microsoft.com/dotnet/aspnet:8.0-preview AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
FROM mcr.microsoft.com/dotnet/sdk:8.0-preview AS build
WORKDIR /src
COPY ["WebGP/WebGP.csproj", "WebGP/"]
COPY ["WebGP.Application/WebGP.Application.csproj", "WebGP.Application/"]
Expand Down
14 changes: 7 additions & 7 deletions WebGP/WebGP.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>6e7f14f2-61a9-4611-94ad-935554790f83</UserSecretsId>
Expand All @@ -11,18 +11,18 @@

<ItemGroup>
<PackageReference Include="MediatR" Version="12.0.1" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.4">
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.0-preview.2.23153.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0-preview.2.23128.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Serilog" Version="2.12.0" />
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog" Version="3.0.0-dev-01926" />
<PackageReference Include="Serilog.AspNetCore" Version="6.1.1-dev-00295" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.1-dev-10338" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.1-dev-00910" />
<PackageReference Include="SSH.NET" Version="2020.0.2" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
Expand Down

0 comments on commit 0dff42b

Please sign in to comment.