Skip to content

Commit

Permalink
+semver: breaking
Browse files Browse the repository at this point in the history
Upgraded to Dotnet 7 and various changes to enable that
  • Loading branch information
Gary Woodfine committed Sep 2, 2023
1 parent af7ee82 commit 3fd8e58
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 45 deletions.
2 changes: 1 addition & 1 deletion Database.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.105
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Threenine.Database.Configuration", "src\Threenine.Database.Configuration.csproj", "{7CFA795D-63F9-4C5C-B427-7282921DC128}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Configuration", "src\Configuration.csproj", "{7CFA795D-63F9-4C5C-B427-7282921DC128}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{F5F29E25-ED8F-4A47-BC35-DDA352EC02DE}"
EndProject
Expand Down
30 changes: 22 additions & 8 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@


<Project>
<PropertyGroup>
<TargetFramework>net6</TargetFramework>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<ImplicitUsings>true</ImplicitUsings>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>disable</Nullable>
<RootNamespace>Threenine</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<Authors>threenine.co.uk</Authors>
<TargetFramework>net7.0</TargetFramework>
<Title>Threenine Database Configuration</Title>
<Description>Provides an opinionated approach and tools </Description>
<RepositoryType>git</RepositoryType>
<PackageTags>bitcoin, lightning</PackageTags>
<RepositoryUrl>https://github.com/threenine/paybolt</RepositoryUrl>
<Copyright>Copyright © $([System.DateTime]::Now.ToString("yyyy")) Three Nine Consulting Limited</Copyright>
<PackageProjectUrl>https://www.threenine.co.uk/paybolt</PackageProjectUrl>
<license>https://github.com/threenine/database.configuration/blob/master/LICENSE</license>
<PackageIcon>icon.png</PackageIcon>
<Version></Version>
<RootNamespace>Threenine.Database</RootNamespace>
</PropertyGroup>
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)icon.png" Pack="true" PackagePath="/">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
MIT License

Copyright (c) 2023 threenine.co.uk
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 6 additions & 1 deletion src/BaseContext.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.ChangeTracking;
using Threenine.Models;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
<PropertyGroup>
<IsPackable>true</IsPackable>
<PackageReadmeFile>README.md</PackageReadmeFile>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.10" />
</ItemGroup>

<ItemGroup>
Expand Down
5 changes: 3 additions & 2 deletions src/Configurations/PostgreSql/BaseEntityTypeConfiguration.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using Threenine.Configurations.PostgreSql;
using Threenine.Models;

namespace Threenine.Configurations.PostgreSql;
namespace Threenine.Database.Configuration.PostgreSql;

public abstract class BaseEntityTypeConfiguration<TEntity> : IEntityTypeConfiguration<TEntity> where TEntity : BaseEntity
{
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
{
builder.ToTable(typeof(TEntity).Name.ToLower());
builder.ToTable(typeof(TEntity).Name.ToSnakeCase());
builder.HasKey(x => x.Id);

builder.Property(e => e.Id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public abstract class ValueListTypeConfiguration<TEntity> : IEntityTypeConfigura
{
public virtual void Configure(EntityTypeBuilder<TEntity> builder)
{
builder.ToTable(typeof(TEntity).Name.ToLower());
builder.ToTable(typeof(TEntity).Name.ToSnakeCase());

builder.HasKey(x => x.Id);

Expand Down
3 changes: 3 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))" />
</Project>
4 changes: 3 additions & 1 deletion src/Models/BaseEntity.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace Threenine.Models;
using System;

namespace Threenine.Models;

public abstract class BaseEntity
{
Expand Down
28 changes: 11 additions & 17 deletions src/README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,14 @@
### Database configuration Helper

A helper to ease the configuration of Entity Framework Cire database projects when using the `IEntityTypeConfiguration` pattern.

In most Enterprise Software solutions database schemas and database design patterns usually comprise of the [Star Schema](https://en.wikipedia.org/wiki/Star_schema) or [Snowflake Schema](https://en.wikipedia.org/wiki/Snowflake_schema) design patterns.

```mermaid
erDiagram
CUSTOMER }|..|{ DELIVERY-ADDRESS : has
CUSTOMER ||--o{ ORDER : places
CUSTOMER ||--o{ INVOICE : "liable for"
DELIVERY-ADDRESS ||--o{ ORDER : receives
INVOICE ||--|{ ORDER : covers
ORDER ||--|{ ORDER-ITEM : includes
PRODUCT-CATEGORY ||--|{ PRODUCT : contains
PRODUCT ||--o{ ORDER-ITEM : "ordered in"
```
### Threenine Database configuration Helper

Provides a helper to ease the configuration of Entity Framework Code First database projects when using the
`IEntityTypeConfiguration` pattern. Offering an opinionated approach to relational database design patterns, with helper
classes to configure both Microsoft SQL Server and PostgreSQL databases, primarily because these are the two most common
relational database engines used in the Enterprise Software solutions and typically what we use at Threenine.








Expand Down
5 changes: 4 additions & 1 deletion tests/Unit/ContextBaseEntityTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
using Shouldly;
using System;
using System.Linq;
using System.Threading.Tasks;
using Shouldly;
using Unit.Tests.TestFixtures;
using Xunit;

Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/ContextValueEntityTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Shouldly;
using System.Linq;
using System.Threading.Tasks;
using Shouldly;
using Unit.Tests.TestFixtures;
using Xunit;

Expand All @@ -21,7 +23,6 @@ public async Task ShouldSaveDateTime()
var save = await repo.AddAsync(new TestValueListEntity { Name = "test" });

await _fixture.Context.SaveChangesAsync();


save.Entity.Id.ShouldBeOfType<int>();
}
Expand Down
3 changes: 3 additions & 0 deletions tests/Unit/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<Project>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)../'))"/>
</Project>
3 changes: 2 additions & 1 deletion tests/Unit/Models/BaseEntityTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using Shouldly;
using Threenine.Models;
using Xunit;
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/Models/ValueListEntityTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.ComponentModel;
using System;
using System.ComponentModel;
using Shouldly;
using Threenine.Models;
using Xunit;
Expand Down
3 changes: 2 additions & 1 deletion tests/Unit/TestFixtures/InMemoryFixture.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore;
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;

namespace Unit.Tests.TestFixtures;
Expand Down
8 changes: 4 additions & 4 deletions tests/Unit/Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="6.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.10" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="7.0.10" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.2.0" />
<PackageReference Include="Moq" Version="4.18.1" />
<PackageReference Include="NBuilder" Version="6.1.0" />
Expand All @@ -26,7 +26,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Threenine.Database.Configuration.csproj" />
<ProjectReference Include="..\..\src\Configuration.csproj" />
</ItemGroup>

</Project>

0 comments on commit 3fd8e58

Please sign in to comment.