Skip to content

Commit 1b981f6

Browse files
authored
Merge branch 'master' into bug/551-Connectionstring
2 parents bf7fe40 + 23af8b9 commit 1b981f6

11 files changed

Lines changed: 73 additions & 54 deletions

File tree

sample/Tracker/Tracker.Core/Tracker.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="AutoMapper" Version="13.0.1" />
1111
<PackageReference Include="FluentValidation" Version="11.9.0" />
1212
<PackageReference Include="Injectio" Version="3.1.0" PrivateAssets="all" />
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
13+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
1414
</ItemGroup>
1515

1616
<ItemGroup>

sample/Tracker/Tracker.Scaffold/Tracker.Scaffold.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
</PropertyGroup>
99

1010
<ItemGroup>
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2">
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3">
1212
<PrivateAssets>all</PrivateAssets>
1313
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
1414
</PackageReference>
15-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
15+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
1616
</ItemGroup>
1717

1818
</Project>

src/Directory.Build.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,10 @@
3232
<PropertyGroup>
3333
<MinVerTagPrefix>v</MinVerTagPrefix>
3434
</PropertyGroup>
35-
35+
3636
<ItemGroup>
3737
<PackageReference Include="AssemblyMetadata.Generators" Version="2.0.0" PrivateAssets="All" />
38-
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
39-
<PackageReference Include="MinVer" Version="4.3.0" PrivateAssets="All" />
38+
<PackageReference Include="MinVer" Version="5.0.0" PrivateAssets="All" />
4039
</ItemGroup>
4140

4241
<ItemGroup>

src/EntityFrameworkCore.Generator.Core/CodeGenerator.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,24 +444,28 @@ private void ConfigureMySqlServices(IServiceCollection services)
444444
{
445445
var designTimeServices = new Pomelo.EntityFrameworkCore.MySql.Design.Internal.MySqlDesignTimeServices();
446446
designTimeServices.ConfigureDesignTimeServices(services);
447+
services.AddEntityFrameworkMySqlNetTopologySuite();
447448
}
448449

449450
private void ConfigurePostgresServices(IServiceCollection services)
450451
{
451452
var designTimeServices = new Npgsql.EntityFrameworkCore.PostgreSQL.Design.Internal.NpgsqlDesignTimeServices();
452453
designTimeServices.ConfigureDesignTimeServices(services);
454+
services.AddEntityFrameworkNpgsqlNetTopologySuite();
453455
}
454456

455457
private void ConfigureSqlServerServices(IServiceCollection services)
456458
{
457459
var designTimeServices = new Microsoft.EntityFrameworkCore.SqlServer.Design.Internal.SqlServerDesignTimeServices();
458460
designTimeServices.ConfigureDesignTimeServices(services);
461+
services.AddEntityFrameworkSqlServerNetTopologySuite();
459462
}
460463

461464
private void ConfigureSqliteServices(IServiceCollection services)
462465
{
463466
var designTimeServices = new Microsoft.EntityFrameworkCore.Sqlite.Design.Internal.SqliteDesignTimeServices();
464467
designTimeServices.ConfigureDesignTimeServices(services);
468+
services.AddEntityFrameworkSqliteNetTopologySuite();
465469
}
466470

467471
private void ConfigureOracleServices(IServiceCollection services)
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net8.0</TargetFramework>
44
<RootNamespace>EntityFrameworkCore.Generator</RootNamespace>
@@ -7,15 +7,19 @@
77

88
<ItemGroup>
99
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.5.0" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.NetTopologySuite" Version="8.0.3" />
11+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer.NetTopologySuite" Version="8.0.3" />
1012
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
11-
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.2" />
12-
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.2" />
13-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.2" />
14-
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.2" />
13+
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL.NetTopologySuite" Version="8.0.2" />
14+
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.3" />
15+
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.NetTopologySuite" Version="8.0.2" />
16+
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="8.0.3" />
17+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
18+
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.3" />
1519
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="8.0.2" />
1620
<PackageReference Include="Oracle.EntityFrameworkCore" Version="8.21.121" />
17-
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.0" />
18-
<PackageReference Include="YamlDotNet" Version="15.1.1" />
21+
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.2" />
22+
<PackageReference Include="YamlDotNet" Version="15.1.2" />
1923
</ItemGroup>
2024

2125
</Project>

src/EntityFrameworkCore.Generator.Core/Options/EntityClassOptions.cs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,6 @@ public EntityClassOptions(VariableDictionary variables, string prefix)
2424
Renaming = new SelectionOptions(variables, AppendPrefix(prefix, "Naming"));
2525
}
2626

27-
/// <summary>
28-
/// Gets or sets the entity class name template.
29-
/// </summary>
30-
/// <value>
31-
/// The entity class name template.
32-
/// </value>
33-
public string Name
34-
{
35-
get => GetProperty();
36-
set => SetProperty(value);
37-
}
38-
39-
/// <summary>
40-
/// Gets or sets the base class to inherit from.
41-
/// </summary>
42-
/// <value>
43-
/// The base class.
44-
/// </value>
45-
public string BaseClass
46-
{
47-
get => GetProperty();
48-
set => SetProperty(value);
49-
}
50-
5127
/// <summary>
5228
/// Gets or sets the entity class naming strategy.
5329
/// </summary>

src/EntityFrameworkCore.Generator.Core/Serialization/EntityClass.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,6 @@ public EntityClass()
2323
PrefixWithSchemaName = false;
2424
}
2525

26-
/// <summary>
27-
/// Gets or sets the entity class name template.
28-
/// </summary>
29-
/// <value>
30-
/// The entity class name template.
31-
/// </value>
32-
public string Name { get; set; }
33-
34-
/// <summary>
35-
/// Gets or sets the base class to inherit from.
36-
/// </summary>
37-
/// <value>
38-
/// The base class.
39-
/// </value>
40-
public string BaseClass { get; set; }
41-
4226
/// <summary>
4327
/// Gets or sets the entity class naming strategy.
4428
/// </summary>

test/EntityFrameworkCore.Generator.Core.Tests/CodeGeneratorTests.cs

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using FluentAssertions;
33
using FluentCommand.SqlServer.Tests;
44
using Microsoft.Extensions.Logging.Abstractions;
5+
using System.IO;
56
using Xunit;
67
using Xunit.Abstractions;
78

@@ -26,6 +27,7 @@ public void Generate()
2627
result.Should().BeTrue();
2728
}
2829

30+
2931
[Fact]
3032
public void Generate_Should_Work_For_Password_With_CurlyBrace()
3133
{
@@ -38,4 +40,39 @@ public void Generate_Should_Work_For_Password_With_CurlyBrace()
3840

3941
result.Should().BeTrue();
4042
}
43+
[Fact]
44+
public void GenerateSpatial()
45+
{
46+
var generatorOptions = new GeneratorOptions();
47+
generatorOptions.Database.ConnectionString = Database.ConnectionString;
48+
49+
var generator = new CodeGenerator(NullLoggerFactory.Instance);
50+
var result = generator.Generate(generatorOptions);
51+
52+
result.Should().BeTrue();
53+
54+
const string spatialTableName = "CitiesSpatial";
55+
56+
var citiesSpatialEntityFile = Path.Combine(generatorOptions.Data.Entity.Directory, spatialTableName + ".cs");
57+
var citiesSpatialMappingFile = Path.Combine(generatorOptions.Data.Mapping.Directory, spatialTableName + "Map.cs");
58+
59+
var citiesSpatialEntityContent = File.ReadAllText(citiesSpatialEntityFile);
60+
var citiesSpatialMappingContent = File.ReadAllText(citiesSpatialMappingFile);
61+
62+
citiesSpatialEntityContent.Contains("public NetTopologySuite.Geometries.Geometry GeometryField { get; set; }").Should().BeTrue();
63+
citiesSpatialEntityContent.Contains("public NetTopologySuite.Geometries.Geometry GeographyField { get; set; }").Should().BeTrue();
64+
65+
citiesSpatialMappingContent.Contains("builder.Property(t => t.GeometryField)" + System.Environment.NewLine +
66+
" .IsRequired()" + System.Environment.NewLine +
67+
" .HasColumnName(\"GeometryField\")" + System.Environment.NewLine +
68+
" .HasColumnType(\"geometry\");").Should().BeTrue();
69+
70+
citiesSpatialMappingContent.Contains("builder.Property(t => t.GeographyField)" + System.Environment.NewLine +
71+
" .IsRequired()" + System.Environment.NewLine +
72+
" .HasColumnName(\"GeographyField\")" + System.Environment.NewLine +
73+
" .HasColumnType(\"geography\");").Should().BeTrue();
74+
75+
}
76+
4177
}
78+

test/EntityFrameworkCore.Generator.Core.Tests/EntityFrameworkCore.Generator.Core.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
</ItemGroup>
2020

2121
<ItemGroup>
22-
<PackageReference Include="coverlet.collector" Version="6.0.1">
22+
<PackageReference Include="coverlet.collector" Version="6.0.2">
2323
<PrivateAssets>all</PrivateAssets>
2424
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
2525
</PackageReference>

test/EntityFrameworkCore.Generator.Core.Tests/Scripts/Script001.Tracker.Schema.sql

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ CREATE TABLE [dbo].[UserRole] (
142142
CONSTRAINT [PK_UserRole] PRIMARY KEY ([UserId], [RoleId])
143143
);
144144

145+
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[CitiesSpatial]') AND type in (N'U'))
146+
CREATE TABLE [dbo].[CitiesSpatial](
147+
[Id] int IDENTITY(1,1) NOT NULL,
148+
[Name] [nvarchar](50) NULL,
149+
[GeometryField] [geometry] NOT NULL,
150+
[GeographyField] [geography] NOT NULL,
151+
CONSTRAINT [PK_CitiesSpatial] PRIMARY KEY ([Id])
152+
)
145153

146154
-- Foreign Keys
147155
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[FK_Task_Priority_PriorityId]') AND parent_object_id = OBJECT_ID(N'[dbo].[Task]'))

0 commit comments

Comments
 (0)