Skip to content

Commit

Permalink
Merge pull request #1 from dojo90/only-use-netstandart2
Browse files Browse the repository at this point in the history
changed target framework to netstandart2.0; added default EF Core v2.…
  • Loading branch information
djonasdev authored Feb 19, 2020
2 parents fe2200d + c379f69 commit 0bbf2be
Show file tree
Hide file tree
Showing 30 changed files with 277 additions and 311 deletions.
4 changes: 2 additions & 2 deletions Directory.build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
<Company>Dominic Jonas</Company>
<Product>DoJo.EntityFrameworkCore.DbContextScope</Product>
<PackageProjectUrl>https://github.com/dojo90/DbContextScope</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/dojo90/DbContextScope/master/LICENSE</PackageLicenseUrl>
<PackageLicense>https://raw.githubusercontent.com/dojo90/DbContextScope/master/LICENSE</PackageLicense>
<RepositoryUrl>[email protected]:dojo90/DbContextScope.git</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>sentinel nlog</PackageTags>
<Description>DbContextScope for EF Core. Forked from https://github.com/tncalvert/DbContextScope. </Description>
<Description>DbContextScope for EF v2|v3 Core. Forked from https://github.com/tncalvert/DbContextScope. </Description>
<PackageTags>EntityFramework EFCore DbContext DbContextScope</PackageTags>
</PropertyGroup>

Expand Down
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
## Foreword

This is a fork from [tncalvert/DbContextScope](https://github.com/tncalvert/DbContextScope). The biggest innovation is the `multitarget support`.
This is a fork from [tncalvert/DbContextScope](https://github.com/tncalvert/DbContextScope). The target framework is `.NET Standart2.0` and minimum `Microsoft.EntityFrameworkCore` version is `v2.0.0`.

- `.NET Framework v4.6.1` -> **Microsoft.EntityFrameworkCore v2.x**
- `.NET CoreApp v2.0` -> **Microsoft.EntityFrameworkCore v2.x**
- `.NET CoreApp v3.0` -> **Microsoft.EntityFrameworkCore v3.x**
If you use this library in your project, please note to use same `nuget versions`! The `DbContextScope` uses `Microsoft.EntityFrameworkCore.Relational v2.0.0`!

Example `*.csproj` to use `v3.1.1`:

```xml
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
```

## Nuget

Expand Down

This file was deleted.

169 changes: 0 additions & 169 deletions src/DbContextScope.DemoConsoleApp/Program.cs

This file was deleted.

23 changes: 23 additions & 0 deletions src/DbContextScope.EF2.Test/DbContextScope.EF2.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<RootNamespace>EntityFrameworkCore.DbContextScope.Test</RootNamespace>
<AssemblyName>DoJo.EntityFrameworkCore.DbContextScope.Test</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="2.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.0.0" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DbContextScope\DbContextScope.csproj" />
</ItemGroup>
</Project>
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Threading.Tasks;
using DbContextScope.DemoConsoleApp.DatabaseContext;
using DbContextScope.DemoConsoleApp.DomainModel;
using EntityFrameworkCore.DbContextScope;
using EntityFrameworkCore.DbContextScope.Test.DatabaseContext;
using EntityFrameworkCore.DbContextScope.Test.DomainModel;

namespace DbContextScope.DemoConsoleApp.Repositories {
namespace EntityFrameworkCore.DbContextScope.Test.Repositories {
/*
* An example "repository" relying on an ambient DbContext instance.
*
Expand Down Expand Up @@ -45,12 +44,14 @@ public User Get(Guid userId) {

public Task<User> GetAsync(Guid userId)
{
#if NETCOREAPP2_0 || NET461
return DbContext.Users.FindAsync(userId);
#endif
#if NETCOREAPP3_0
return DbContext.Users.FindAsync(userId).AsTask();
#endif

//#if NETCOREAPP2_0 || NET461
// return DbContext.Users.FindAsync(userId);
//#endif
//#if NETCOREAPP3_0
// return DbContext.Users.FindAsync(userId).AsTask();
//#endif
}

public void Add(User user) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using DbContextScope.DemoConsoleApp.CommandModel;
using DbContextScope.DemoConsoleApp.DomainModel;
using DbContextScope.DemoConsoleApp.Repositories;
using EntityFrameworkCore.DbContextScope;
using EntityFrameworkCore.DbContextScope.Test.CommandModel;
using EntityFrameworkCore.DbContextScope.Test.DomainModel;
using EntityFrameworkCore.DbContextScope.Test.Repositories;

namespace DbContextScope.DemoConsoleApp.BusinessLogicServices {
namespace EntityFrameworkCore.DbContextScope.Test.BusinessLogicServices {
/*
* Example business logic service implementing command functionalities (i.e. create / update actions).
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using DbContextScope.DemoConsoleApp.DatabaseContext;
using EntityFrameworkCore.DbContextScope;
using EntityFrameworkCore.DbContextScope.Test.DatabaseContext;

namespace DbContextScope.DemoConsoleApp.BusinessLogicServices {
namespace EntityFrameworkCore.DbContextScope.Test.BusinessLogicServices {
public class UserCreditScoreService {
private readonly IDbContextScopeFactory _dbContextScopeFactory;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
using System;
using System.Collections.Generic;
using DbContextScope.DemoConsoleApp.DatabaseContext;
using DbContextScope.DemoConsoleApp.DomainModel;
using EntityFrameworkCore.DbContextScope;
using EntityFrameworkCore.DbContextScope.Test.DatabaseContext;
using EntityFrameworkCore.DbContextScope.Test.DomainModel;

namespace DbContextScope.DemoConsoleApp.BusinessLogicServices {
namespace EntityFrameworkCore.DbContextScope.Test.BusinessLogicServices {
public class UserEmailService {
private readonly IDbContextScopeFactory _dbContextScopeFactory;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using DbContextScope.DemoConsoleApp.DatabaseContext;
using DbContextScope.DemoConsoleApp.DomainModel;
using DbContextScope.DemoConsoleApp.Repositories;
using EntityFrameworkCore.DbContextScope;
using EntityFrameworkCore.DbContextScope.Test.DatabaseContext;
using EntityFrameworkCore.DbContextScope.Test.DomainModel;
using EntityFrameworkCore.DbContextScope.Test.Repositories;

namespace DbContextScope.DemoConsoleApp.BusinessLogicServices {
namespace EntityFrameworkCore.DbContextScope.Test.BusinessLogicServices {
/*
* Example business logic service implementing query functionalities (i.e. read actions).
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;

namespace DbContextScope.DemoConsoleApp.CommandModel {
namespace EntityFrameworkCore.DbContextScope.Test.CommandModel {
/// <summary>
/// Specifications of the CreateUser command. Defines the properties of a new user.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using DbContextScope.DemoConsoleApp.DomainModel;
using EntityFrameworkCore.DbContextScope.Test.DomainModel;
using Microsoft.EntityFrameworkCore;

namespace DbContextScope.DemoConsoleApp.DatabaseContext {
namespace EntityFrameworkCore.DbContextScope.Test.DatabaseContext {
public class UserManagementDbContext : DbContext {
// Map our 'User' model by convention
public DbSet<User> Users { get; set; }
Expand Down
23 changes: 23 additions & 0 deletions src/DbContextScope.EF3.Test/DbContextScope.EF3.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net461;netcoreapp2.0;netcoreapp3.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<RootNamespace>EntityFrameworkCore.DbContextScope.Test</RootNamespace>
<AssemblyName>DoJo.EntityFrameworkCore.DbContextScope.Test</AssemblyName>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.2.0" />
<PackageReference Include="xunit" Version="2.4.0" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.0" />
<PackageReference Include="coverlet.collector" Version="1.0.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\DbContextScope\DbContextScope.csproj" />
</ItemGroup>
</Project>
Loading

0 comments on commit 0bbf2be

Please sign in to comment.