Skip to content

Commit

Permalink
Clean up PR #112
Browse files Browse the repository at this point in the history
  • Loading branch information
bricelam committed Sep 29, 2022
1 parent 4fc0b5d commit 8559196
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 50 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ name: .NET
on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
build:

runs-on: windows-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Setup .NET
uses: actions/setup-dotnet@v1
uses: actions/setup-dotnet@v2
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.100-rc.1.22431.12
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<IsPackable>false</IsPackable>
<AssemblyName>EntityFrameworkCore.InMemory.HierarchyId.Test</AssemblyName>
<RootNamespace>Microsoft.EntityFrameworkCore.InMemory</RootNamespace>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="dotMorten.Microsoft.SqlServer.Types" Version="1.4.0" />
<PackageReference Include="dotMorten.Microsoft.SqlServer.Types" Version="1.5.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0-2.final" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.3.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational.Specification.Tests" Version="7.0.0-rc.1.22426.7" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.0-rc.1.22426.7" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="7.0.0-rc.1.22426.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ public void Loads_HierarchyId_columns()
},
column =>
{
Assert.Equal("hierarchy", column.GetColumnBaseName());
Assert.Equal("hierarchy", column.GetColumnName());
Assert.Equal(typeof(HierarchyId), column.ClrType);
},
column =>
{
Assert.Equal("occupation", column.GetColumnBaseName());
Assert.Equal("occupation", column.GetColumnName());
Assert.Equal(typeof(string), column.ClrType);
},
column =>
{
Assert.Equal("salary", column.GetColumnBaseName());
Assert.Equal("salary", column.GetColumnName());
Assert.Equal(typeof(int?), column.ClrType);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ public override string GetExpectedMigrationCode(string migrationName, string roo
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace MyApp.Data.Migrations
namespace {rootNamespace}.Migrations
{{
/// <inheritdoc />
public partial class MyMigration : Migration
public partial class {migrationName} : Migration
{{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{{
migrationBuilder.CreateTable(
name: ""ConvertedTestModels"",
name: ""{nameof(ConvertedTestModels)}"",
columns: table => new
{{
Id = table.Column<int>(type: ""int"", nullable: false),
HierarchyId = table.Column<HierarchyId>(type: ""hierarchyid"", nullable: true),
HierarchyId = table.Column<{nameof(HierarchyId)}>(type: ""hierarchyid"", nullable: true),
Name = table.Column<string>(type: ""nvarchar(max)"", nullable: true)
}},
constraints: table =>
Expand All @@ -56,15 +56,15 @@ protected override void Up(MigrationBuilder migrationBuilder)
}});
migrationBuilder.CreateTable(
name: ""TestModels"",
name: ""{nameof(TestModels)}"",
columns: table => new
{{
Id = table.Column<HierarchyId>(type: ""hierarchyid"", nullable: false),
Name = table.Column<string>(type: ""nvarchar(max)"", nullable: true)
{nameof(Patriarch.Id)} = table.Column<{nameof(HierarchyId)}>(type: ""hierarchyid"", nullable: false),
{nameof(Patriarch.Name)} = table.Column<string>(type: ""nvarchar(max)"", nullable: true)
}},
constraints: table =>
{{
table.PrimaryKey(""PK_TestModels"", x => x.Id);
table.PrimaryKey(""PK_{nameof(TestModels)}"", x => x.{nameof(Patriarch.Id)});
}});
migrationBuilder.InsertData(
Expand Down Expand Up @@ -95,7 +95,7 @@ protected override void Down(MigrationBuilder migrationBuilder)
name: ""ConvertedTestModels"");
migrationBuilder.DropTable(
name: ""TestModels"");
name: ""{nameof(TestModels)}"");
}}
}}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,57 +34,57 @@ public override string GetExpectedMigrationCode(string migrationName, string roo
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace MyApp.Data.Migrations
namespace {rootNamespace}.Migrations
{{
/// <inheritdoc />
public partial class MyMigration : Migration
public partial class {migrationName} : Migration
{{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{{
migrationBuilder.CreateTable(
name: ""ConvertedTestModels"",
name: ""{nameof(ConvertedTestModels)}"",
columns: table => new
{{
Id = table.Column<int>(type: ""int"", nullable: false),
HierarchyId = table.Column<HierarchyId>(type: ""hierarchyid"", nullable: true),
Name = table.Column<string>(type: ""nvarchar(max)"", nullable: true)
{nameof(ConvertedPatriarch.Id)} = table.Column<int>(type: ""int"", nullable: false),
{nameof(ConvertedPatriarch.HierarchyId)} = table.Column<{nameof(HierarchyId)}>(type: ""hierarchyid"", nullable: true),
{nameof(ConvertedPatriarch.Name)} = table.Column<string>(type: ""nvarchar(max)"", nullable: true)
}},
constraints: table =>
{{
table.PrimaryKey(""PK_ConvertedTestModels"", x => x.Id);
table.PrimaryKey(""PK_{nameof(ConvertedTestModels)}"", x => x.{nameof(ConvertedPatriarch.Id)});
}});
migrationBuilder.CreateTable(
name: ""TestModels"",
name: ""{nameof(TestModels)}"",
columns: table => new
{{
Id = table.Column<HierarchyId>(type: ""hierarchyid"", nullable: false),
Name = table.Column<string>(type: ""nvarchar(max)"", nullable: true)
{nameof(Patriarch.Id)} = table.Column<{nameof(HierarchyId)}>(type: ""hierarchyid"", nullable: false),
{nameof(Patriarch.Name)} = table.Column<string>(type: ""nvarchar(max)"", nullable: true)
}},
constraints: table =>
{{
table.PrimaryKey(""PK_TestModels"", x => x.Id);
table.PrimaryKey(""PK_{nameof(TestModels)}"", x => x.{nameof(Patriarch.Id)});
}});
migrationBuilder.InsertData(
table: ""ConvertedTestModels"",
columns: new[] {{ ""Id"", ""HierarchyId"", ""Name"" }},
values: new object[,]
{{
{{ 1, Microsoft.EntityFrameworkCore.HierarchyId.Parse(""/""), ""Eddard Stark"" }},
{{ 2, Microsoft.EntityFrameworkCore.HierarchyId.Parse(""/1/""), ""Robb Stark"" }},
{{ 3, Microsoft.EntityFrameworkCore.HierarchyId.Parse(""/2/""), ""Jon Snow"" }}
{{ 1, {typeof(HierarchyId).FullName}.Parse(""/""), ""Eddard Stark"" }},
{{ 2, {typeof(HierarchyId).FullName}.Parse(""/1/""), ""Robb Stark"" }},
{{ 3, {typeof(HierarchyId).FullName}.Parse(""/2/""), ""Jon Snow"" }}
}});
migrationBuilder.InsertData(
table: ""TestModels"",
columns: new[] {{ ""Id"", ""Name"" }},
values: new object[,]
{{
{{ Microsoft.EntityFrameworkCore.HierarchyId.Parse(""/""), ""Eddard Stark"" }},
{{ Microsoft.EntityFrameworkCore.HierarchyId.Parse(""/1/""), ""Robb Stark"" }},
{{ Microsoft.EntityFrameworkCore.HierarchyId.Parse(""/2/""), ""Jon Snow"" }}
{{ {typeof(HierarchyId).FullName}.Parse(""/""), ""Eddard Stark"" }},
{{ {typeof(HierarchyId).FullName}.Parse(""/1/""), ""Robb Stark"" }},
{{ {typeof(HierarchyId).FullName}.Parse(""/2/""), ""Jon Snow"" }}
}});
}}
Expand All @@ -95,7 +95,7 @@ protected override void Down(MigrationBuilder migrationBuilder)
name: ""ConvertedTestModels"");
migrationBuilder.DropTable(
name: ""TestModels"");
name: ""{nameof(TestModels)}"");
}}
}}
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Linq;
using Microsoft.EntityFrameworkCore.Design;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Scaffolding;
Expand All @@ -22,7 +21,6 @@ public FakeScaffoldingModelFactory(
IPluralizer pluralizer,
ICSharpUtilities cSharpUtilities,
IScaffoldingTypeMapper scaffoldingTypeMapper,
LoggingDefinitions loggingDefinitions,
IModelRuntimeInitializer modelRuntimeInitializer)
: base(reporter, candidateNamingService, pluralizer, cSharpUtilities, scaffoldingTypeMapper,
modelRuntimeInitializer)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ public override IServiceCollection AddProviderServices(IServiceCollection servic
=> services.AddEntityFrameworkSqlServer();

public override DbContextOptionsBuilder UseProviderOptions(DbContextOptionsBuilder optionsBuilder)
{
return optionsBuilder.UseSqlServer(new SqlConnection("Database=DummyDatabase"));
}
//public override void UseProviderOptions(DbContextOptionsBuilder optionsBuilder)
// => optionsBuilder.UseSqlServer(new SqlConnection("Database=DummyDatabase"));
=> optionsBuilder.UseSqlServer(new SqlConnection("Database=DummyDatabase"));

public override LoggingDefinitions LoggingDefinitions { get; } = new SqlServerLoggingDefinitions();
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ protected override string GenerateNonNullSqlLiteral(object value)
//command, and the value is already a hierarchyid
return $"'{value}'";
}

public override DbParameter CreateParameter(DbCommand command, string name, object value, bool? nullable = null, ParameterDirection direction = ParameterDirection.Input)
{
var parameter = command.CreateParameter();
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ The following table show which version of this library to use with which version

| EF Core | Version to use |
| ------- | --------------- |
| 7.0 | 4.x |
| 6.0 | 3.x |
| 5.0 | 2.x |
| 3.1 | 1.x |

Usage
Expand Down

0 comments on commit 8559196

Please sign in to comment.