diff --git a/AutoMapper.AspNetCore.OData.EF6/AutoMapper.AspNetCore.OData.EF6.csproj b/AutoMapper.AspNetCore.OData.EF6/AutoMapper.AspNetCore.OData.EF6.csproj index 4f1aa4c..a69db5b 100644 --- a/AutoMapper.AspNetCore.OData.EF6/AutoMapper.AspNetCore.OData.EF6.csproj +++ b/AutoMapper.AspNetCore.OData.EF6/AutoMapper.AspNetCore.OData.EF6.csproj @@ -6,7 +6,7 @@ AutoMapper.AspNetCore.OData.EF6 Creates LINQ expressions from ODataQueryOptions and executes the query. false - Supporting AutoMapper v12. + Supporting AutoMapper v13 (EF Core only). linq expressions odata efcore icon.png https://github.com/AutoMapper/AutoMapper.Extensions.OData @@ -56,14 +56,16 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + diff --git a/AutoMapper.AspNetCore.OData.EFCore/AutoMapper.AspNetCore.OData.EFCore.csproj b/AutoMapper.AspNetCore.OData.EFCore/AutoMapper.AspNetCore.OData.EFCore.csproj index 5589d2f..0a51aad 100644 --- a/AutoMapper.AspNetCore.OData.EFCore/AutoMapper.AspNetCore.OData.EFCore.csproj +++ b/AutoMapper.AspNetCore.OData.EFCore/AutoMapper.AspNetCore.OData.EFCore.csproj @@ -6,7 +6,7 @@ AutoMapper.AspNetCore.OData.EFCore Creates LINQ expressions from ODataQueryOptions and executes the query. false - Supporting AutoMapper v12. + Supporting AutoMapper v13 (EF Core only). linq expressions odata efcore icon.png https://github.com/AutoMapper/AutoMapper.Extensions.OData @@ -28,14 +28,14 @@ - + - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + @@ -47,7 +47,7 @@ - + diff --git a/AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj b/AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj index 98a6feb..3e1a2cc 100644 --- a/AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj +++ b/AutoMapper.OData.EF6.Tests/AutoMapper.OData.EF6.Tests.csproj @@ -7,13 +7,13 @@ - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/AutoMapper.OData.EFCore.Tests/AutoMapper.OData.EFCore.Tests.csproj b/AutoMapper.OData.EFCore.Tests/AutoMapper.OData.EFCore.Tests.csproj index 680b88d..32d52ee 100644 --- a/AutoMapper.OData.EFCore.Tests/AutoMapper.OData.EFCore.Tests.csproj +++ b/AutoMapper.OData.EFCore.Tests/AutoMapper.OData.EFCore.Tests.csproj @@ -7,10 +7,10 @@ - - - - + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/AutoMapper.OData.EFCore.Tests/GetQuerySelectTests.cs b/AutoMapper.OData.EFCore.Tests/GetQuerySelectTests.cs index 3a0b4d6..9027dd6 100644 --- a/AutoMapper.OData.EFCore.Tests/GetQuerySelectTests.cs +++ b/AutoMapper.OData.EFCore.Tests/GetQuerySelectTests.cs @@ -15,48 +15,20 @@ namespace AutoMapper.OData.EFCore.Tests { - public class GetQuerySelectTests + public class GetQuerySelectTests : IClassFixture { - public GetQuerySelectTests() + private readonly GetQuerySelectTestsFixture _fixture; + + public GetQuerySelectTests(GetQuerySelectTestsFixture fixture) { - Initialize(); + _fixture = fixture; + serviceProvider = _fixture.ServiceProvider; } #region Fields - private IServiceProvider serviceProvider; + private readonly IServiceProvider serviceProvider; #endregion Fields - private void Initialize() - { - IServiceCollection services = new ServiceCollection(); - IMvcCoreBuilder builder = new TestMvcCoreBuilder - { - Services = services - }; - - builder.AddOData(); - services.AddDbContext - ( - options => - { - options.UseInMemoryDatabase("MyDbContext"); - options.UseInternalServiceProvider(new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider()); - }, - ServiceLifetime.Transient - ) - .AddSingleton(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly))) - .AddTransient(sp => new Mapper(sp.GetRequiredService(), sp.GetService)) - .AddTransient(sp => new ApplicationBuilder(sp)) - .AddRouting() - .AddLogging(); - - serviceProvider = services.BuildServiceProvider(); - - MyDbContext context = serviceProvider.GetRequiredService(); - context.Database.EnsureCreated(); - DatabaseInitializer.SeedDatabase(context); - } - [Fact] public async void OpsTenantSelectNameExpandBuildings() { @@ -84,7 +56,7 @@ public async void OpsTenantExpandBuildingsFilterEqAndOrderBy_FirstBuildingHasVal void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(2, collection.First().Buildings.Count); Assert.NotNull(collection.First().Buildings.First().Name); Assert.NotEqual(default, collection.First().Buildings.First().Identity); @@ -103,7 +75,7 @@ public async void BuildingSelectNameExpandBuilder_BuilderNameShouldBeSam() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("Sam", collection.First().Builder.Name); Assert.Equal(default, collection.First().Builder.Id); Assert.Null(collection.First().Builder.City); @@ -122,7 +94,7 @@ public async void BuildingExpandBuilderSelectNamefilterEqAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("Sam", collection.First().Builder.Name); Assert.Equal(default, collection.First().Builder.Id); Assert.Null(collection.First().Builder.City); @@ -141,7 +113,7 @@ public async void BuildingExpandBuilderSelectNameExpandCityFilterEqAndOrderBy_Ci void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("Sam", collection.First().Builder.Name); Assert.Equal(default, collection.First().Builder.Id); Assert.Equal("London", collection.First().Builder.City.Name); @@ -220,4 +192,41 @@ private ODataQueryOptions GetODataQueryOptions(string query, str ); } } + + public class GetQuerySelectTestsFixture + { + public GetQuerySelectTestsFixture() + { + IServiceCollection services = new ServiceCollection(); + IMvcCoreBuilder builder = new TestMvcCoreBuilder + { + Services = services + }; + + builder.AddOData(); + services.AddDbContext + ( + options => options.UseSqlServer + ( + @"Server=(localdb)\mssqllocaldb;Database=GetQuerySelectTestsatabase;ConnectRetryCount=0", + options => options.EnableRetryOnFailure() + ), + ServiceLifetime.Transient + ) + .AddSingleton(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly))) + .AddTransient(sp => new Mapper(sp.GetRequiredService(), sp.GetService)) + .AddTransient(sp => new ApplicationBuilder(sp)) + .AddRouting() + .AddLogging(); + + ServiceProvider = services.BuildServiceProvider(); + + MyDbContext context = ServiceProvider.GetRequiredService(); + context.Database.EnsureDeleted(); + context.Database.EnsureCreated(); + DatabaseInitializer.SeedDatabase(context); + } + + internal IServiceProvider ServiceProvider; + } } diff --git a/AutoMapper.OData.EFCore.Tests/GetQueryTests.cs b/AutoMapper.OData.EFCore.Tests/GetQueryTests.cs index 5c9059b..14b11a8 100644 --- a/AutoMapper.OData.EFCore.Tests/GetQueryTests.cs +++ b/AutoMapper.OData.EFCore.Tests/GetQueryTests.cs @@ -18,48 +18,20 @@ namespace AutoMapper.OData.EFCore.Tests { - public class GetQueryTests + public class GetQueryTests : IClassFixture { - public GetQueryTests() + private readonly GetQueryTestsFixture _fixture; + + public GetQueryTests(GetQueryTestsFixture fixture) { - Initialize(); + _fixture = fixture; + serviceProvider = _fixture.ServiceProvider; } #region Fields - private IServiceProvider serviceProvider; + private readonly IServiceProvider serviceProvider; #endregion Fields - private void Initialize() - { - IServiceCollection services = new ServiceCollection(); - IMvcCoreBuilder builder = new TestMvcCoreBuilder - { - Services = services - }; - - builder.AddOData(); - services.AddDbContext - ( - options => - { - options.UseInMemoryDatabase("MyDbContext"); - options.UseInternalServiceProvider(new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider()); - }, - ServiceLifetime.Transient - ) - .AddSingleton(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly))) - .AddTransient(sp => new Mapper(sp.GetRequiredService(), sp.GetService)) - .AddTransient(sp => new ApplicationBuilder(sp)) - .AddRouting() - .AddLogging(); - - serviceProvider = services.BuildServiceProvider(); - - MyDbContext context = serviceProvider.GetRequiredService(); - context.Database.EnsureCreated(); - DatabaseInitializer.SeedDatabase(context); - } - [Fact] public void IsConfigurationValid() { @@ -76,7 +48,7 @@ public async void OpsTenantSearch() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("One", collection.First().Name); } } @@ -91,7 +63,7 @@ public async void OpsTenantSearchAndFilter() void Test(ICollection collection) { - Assert.Equal(0, collection.Count); + Assert.Empty(collection); } } @@ -161,7 +133,7 @@ public async void OpsTenantExpandBuildingsFilterEqAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(2, collection.First().Buildings.Count); Assert.Equal("One", collection.First().Name); } @@ -210,7 +182,7 @@ public async void OpsTenantExpandBuildingsFilterNeAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(3, collection.First().Buildings.Count); Assert.Equal("Two", collection.First().Name); } @@ -226,7 +198,7 @@ public async void OpsTenantFilterEqNoExpand() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Null(collection.First().Buildings); Assert.Equal("One", collection.First().Name); } @@ -258,7 +230,7 @@ public async void OpsTenantFilterLtDateNoExpand() void Test(ICollection collection) { - Assert.Equal(0, collection.Count); + Assert.Empty(collection); } } @@ -304,7 +276,7 @@ public async void OpsTenantNoExpandFilterEqAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Null(collection.First().Buildings); Assert.Equal("One", collection.First().Name); } @@ -320,7 +292,7 @@ public async void OpsTenantExpandBuildingsSelectNameAndBuilderExpandBuilderExpan void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(3, collection.First().Buildings.Count); Assert.NotNull(collection.First().Buildings.First().Builder); Assert.NotNull(collection.First().Buildings.First().Builder.City); @@ -339,7 +311,7 @@ public async void OpsTenantExpandBuildingsExpandBuilderExpandCityFilterNeAndOrde void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(3, collection.First().Buildings.Count); Assert.NotNull(collection.First().Buildings.First().Builder); Assert.NotNull(collection.First().Buildings.First().Builder.City); @@ -403,7 +375,7 @@ await GetUsingCustomNameSpace void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("One L1", collection.First().Name); Assert.Equal(buildingParameterValue, collection.First().Parameter); Assert.Equal("Sam", collection.First().Builder.Name); @@ -421,7 +393,7 @@ public async void BuildingExpandBuilderTenantFilterEqAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("Sam", collection.First().Builder.Name); Assert.Equal("One", collection.First().Tenant.Name); Assert.Equal("One L1", collection.First().Name); @@ -439,7 +411,7 @@ public async void BuildingExpandBuilderSelectNameExpandTenantFilterEqAndOrderBy( void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("Sam", collection.First().Builder.Name); Assert.Equal("One", collection.First().Tenant.Name); Assert.Equal("One L1", collection.First().Name); @@ -574,7 +546,7 @@ public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Ta void Test(ICollection collection) { Assert.Equal(5, options.Request.ODataFeature().TotalCount); - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("London", collection.First().Builder.City.Name); Assert.Equal("One L1", collection.First().Name); } @@ -597,7 +569,7 @@ public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Ta void Test(ICollection collection) { Assert.Null(options.Request.ODataFeature().TotalCount); - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("London", collection.First().Builder.City.Name); Assert.Equal("One L1", collection.First().Name); } @@ -1141,7 +1113,7 @@ await GetUsingCustomNameSpace static void Test(ICollection collection) { Assert.Equal(2, collection.Count); - Assert.Equal(1, collection.First().Products.Count); + Assert.Single(collection.First().Products); Assert.Equal(2, collection.First().Products.First().AlternateAddresses.Count()); } } @@ -1193,9 +1165,9 @@ public async void SkipOnRootNoOrderByThenExpandAndSkipOnChildCollectionNoOrderBy static void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(2, collection.First().CategoryID); - Assert.Equal(1, collection.First().Products.Count); + Assert.Single(collection.First().Products); Assert.Equal(5, collection.First().Products.First().ProductID); Assert.Equal(2, collection.First().Products.First().AlternateAddresses.Length); Assert.Equal(4, collection.First().Products.First().AlternateAddresses.First().AddressID); @@ -1213,9 +1185,9 @@ public async void SkipOnRootNoOrderByThenExpandAndSkipOnChildCollectionNoOrderBy static void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(2, collection.First().CategoryID); - Assert.Equal(1, collection.First().Products.Count); + Assert.Single(collection.First().Products); Assert.Equal(5, collection.First().Products.First().ProductID); Assert.Equal(2, collection.First().Products.First().AlternateAddresses.Length); Assert.Equal(4, collection.First().Products.First().AlternateAddresses.First().AddressID); @@ -1235,7 +1207,7 @@ static void Test(ICollection collection) { Assert.Equal(2, collection.First().Products.First().ProductID); Assert.Equal(3, collection.First().Products.Last().ProductID); - Assert.Equal(1, collection.Last().Products.Count); + Assert.Single(collection.Last().Products); Assert.Equal(5, collection.Last().Products.First().ProductID); } } @@ -1313,7 +1285,7 @@ public async void SkipOnRootNoOrderBy() static void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(2, collection.First().CategoryID); } } @@ -1423,4 +1395,41 @@ private ODataQueryOptions GetODataQueryOptions(string query, str ); } } + + public class GetQueryTestsFixture + { + public GetQueryTestsFixture() + { + IServiceCollection services = new ServiceCollection(); + IMvcCoreBuilder builder = new TestMvcCoreBuilder + { + Services = services + }; + + builder.AddOData(); + services.AddDbContext + ( + options => options.UseSqlServer + ( + @"Server=(localdb)\mssqllocaldb;Database=GetQueryTestsDatabase;ConnectRetryCount=0", + options => options.EnableRetryOnFailure() + ), + ServiceLifetime.Transient + ) + .AddSingleton(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly))) + .AddTransient(sp => new Mapper(sp.GetRequiredService(), sp.GetService)) + .AddTransient(sp => new ApplicationBuilder(sp)) + .AddRouting() + .AddLogging(); + + ServiceProvider = services.BuildServiceProvider(); + + MyDbContext context = ServiceProvider.GetRequiredService(); + context.Database.EnsureDeleted(); + context.Database.EnsureCreated(); + DatabaseInitializer.SeedDatabase(context); + } + + internal IServiceProvider ServiceProvider; + } } diff --git a/AutoMapper.OData.EFCore.Tests/GetTests.cs b/AutoMapper.OData.EFCore.Tests/GetTests.cs index 5a85ef7..ae3e4e7 100644 --- a/AutoMapper.OData.EFCore.Tests/GetTests.cs +++ b/AutoMapper.OData.EFCore.Tests/GetTests.cs @@ -1,4 +1,5 @@ using AutoMapper.AspNet.OData; +using AutoMapper.OData.EFCore.Tests.Binders; using AutoMapper.OData.EFCore.Tests.Data; using DAL.EFCore; using Domain.OData; @@ -8,6 +9,7 @@ using Microsoft.AspNetCore.OData; using Microsoft.AspNetCore.OData.Extensions; using Microsoft.AspNetCore.OData.Query; +using Microsoft.AspNetCore.OData.Query.Expressions; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using Microsoft.OData.Edm; @@ -18,55 +20,24 @@ using System.Linq; using System.Threading; using System.Threading.Tasks; -using AutoMapper.OData.EFCore.Tests.Binders; -using Microsoft.AspNetCore.OData.Query.Expressions; using Xunit; -using AutoMapper.OData.EFCore.Tests.Model; namespace AutoMapper.OData.EFCore.Tests { - public class GetTests + public class GetTests : IClassFixture { - public GetTests() + private readonly GetTestsFixture _fixture; + + public GetTests(GetTestsFixture fixture) { - Initialize(); + _fixture = fixture; + serviceProvider = _fixture.ServiceProvider; } #region Fields - private IServiceProvider serviceProvider; + private readonly IServiceProvider serviceProvider; #endregion Fields - private void Initialize() - { - IServiceCollection services = new ServiceCollection(); - IMvcCoreBuilder builder = new TestMvcCoreBuilder - { - Services = services - }; - - builder.AddOData(); - services.AddDbContext - ( - options => - { - options.UseInMemoryDatabase("MyDbContext"); - options.UseInternalServiceProvider(new ServiceCollection().AddEntityFrameworkInMemoryDatabase().BuildServiceProvider()); - }, - ServiceLifetime.Transient - ) - .AddSingleton(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly))) - .AddTransient(sp => new Mapper(sp.GetRequiredService(), sp.GetService)) - .AddTransient(sp => new ApplicationBuilder(sp)) - .AddRouting() - .AddLogging(); - - serviceProvider = services.BuildServiceProvider(); - - MyDbContext context = serviceProvider.GetRequiredService(); - context.Database.EnsureCreated(); - DatabaseInitializer.SeedDatabase(context); - } - [Fact] public async void OpsTenantCreatedOnFilterServerUTCTimeZone() { @@ -133,7 +104,7 @@ public async void OpsTenantExpandBuildingsFilterEqAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(2, collection.First().Buildings.Count); Assert.Equal("One", collection.First().Name); } @@ -149,7 +120,7 @@ public async void OpsTenantExpandBuildingsFilterNeAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(3, collection.First().Buildings.Count); Assert.Equal("Two", collection.First().Name); } @@ -165,8 +136,8 @@ public async void OpsTenantFilterEqNoExpand() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); - Assert.Equal(0, collection.First().Buildings.Count); + Assert.Single(collection); + Assert.Empty(collection.First().Buildings); Assert.Equal("One", collection.First().Name); } } @@ -198,7 +169,7 @@ public async void OpsTenantNoExpandNoFilterAndOrderBy() void Test(ICollection collection) { Assert.Equal(2, collection.Count); - Assert.Equal(0, collection.First().Buildings.Count); + Assert.Empty(collection.First().Buildings); Assert.Equal("Two", collection.First().Name); } } @@ -213,8 +184,8 @@ public async void OpsTenantNoExpandFilterEqAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); - Assert.Equal(0, collection.First().Buildings.Count); + Assert.Single(collection); + Assert.Empty(collection.First().Buildings); Assert.Equal("One", collection.First().Name); } } @@ -229,7 +200,7 @@ public async void OpsTenantExpandBuildingsExpandBuilderExpandCityFilterNeAndOrde void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal(3, collection.First().Buildings.Count); Assert.NotNull(collection.First().Buildings.First().Builder); Assert.NotNull(collection.First().Buildings.First().Builder.City); @@ -247,7 +218,7 @@ public async void BuildingExpandBuilderTenantFilterEqAndOrderBy() void Test(ICollection collection) { - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("Sam", collection.First().Builder.Name); Assert.Equal("One", collection.First().Tenant.Name); Assert.Equal("One L1", collection.First().Name); @@ -382,7 +353,7 @@ public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Ta void Test(ICollection collection) { Assert.Equal(5, options.Request.ODataFeature().TotalCount); - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("London", collection.First().Builder.City.Name); Assert.Equal("One L1", collection.First().Name); } @@ -405,7 +376,7 @@ public async void BuildingExpandBuilderTenantExpandCityOrderByBuilderNameSkip3Ta void Test(ICollection collection) { Assert.Null(options.Request.ODataFeature().TotalCount); - Assert.Equal(1, collection.Count); + Assert.Single(collection); Assert.Equal("London", collection.First().Builder.City.Name); Assert.Equal("One L1", collection.First().Name); } @@ -757,4 +728,41 @@ internal class TestMvcCoreBuilder : IMvcCoreBuilder public ApplicationPartManager PartManager { get; set; } public IServiceCollection Services { get; set; } } + + public class GetTestsFixture + { + public GetTestsFixture() + { + IServiceCollection services = new ServiceCollection(); + IMvcCoreBuilder builder = new TestMvcCoreBuilder + { + Services = services + }; + + builder.AddOData(); + services.AddDbContext + ( + options => options.UseSqlServer + ( + @"Server=(localdb)\mssqllocaldb;Database=GetTestsDatabase;ConnectRetryCount=0", + options => options.EnableRetryOnFailure() + ), + ServiceLifetime.Transient + ) + .AddSingleton(new MapperConfiguration(cfg => cfg.AddMaps(typeof(GetTests).Assembly))) + .AddTransient(sp => new Mapper(sp.GetRequiredService(), sp.GetService)) + .AddTransient(sp => new ApplicationBuilder(sp)) + .AddRouting() + .AddLogging(); + + ServiceProvider = services.BuildServiceProvider(); + + MyDbContext context = ServiceProvider.GetRequiredService(); + context.Database.EnsureDeleted(); + context.Database.EnsureCreated(); + DatabaseInitializer.SeedDatabase(context); + } + + internal IServiceProvider ServiceProvider; + } } diff --git a/DAL.EF6/DAL.EF6.csproj b/DAL.EF6/DAL.EF6.csproj index 7715105..3124ff7 100644 --- a/DAL.EF6/DAL.EF6.csproj +++ b/DAL.EF6/DAL.EF6.csproj @@ -5,7 +5,8 @@ - + + diff --git a/DAL.EFCore/DAL.EFCore.csproj b/DAL.EFCore/DAL.EFCore.csproj index f412e4f..58729ad 100644 --- a/DAL.EFCore/DAL.EFCore.csproj +++ b/DAL.EFCore/DAL.EFCore.csproj @@ -13,7 +13,7 @@ - + diff --git a/Domain.OData/Domain.OData.csproj b/Domain.OData/Domain.OData.csproj index 606e1e6..d1f7d6c 100644 --- a/Domain.OData/Domain.OData.csproj +++ b/Domain.OData/Domain.OData.csproj @@ -5,7 +5,7 @@ - + diff --git a/ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj b/ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj index 20514de..78045b6 100644 --- a/ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj +++ b/ExpressionBuilder.Tests/ExpressionBuilder.Tests.csproj @@ -7,10 +7,9 @@ - - - - + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/ExpressionBuilder.Tests/FilterTests.cs b/ExpressionBuilder.Tests/FilterTests.cs index 8177d42..201ba7b 100644 --- a/ExpressionBuilder.Tests/FilterTests.cs +++ b/ExpressionBuilder.Tests/FilterTests.cs @@ -2636,7 +2636,7 @@ public void Isof_WithNullTypeName_ThrowsArgumentNullException(string filterStrin var exception = Assert.Throws(() => GetFilter(filterString)); Assert.Equal ( - "Value cannot be null. (Parameter 'qualifiedName')", + "Value cannot be null. (Parameter 'typeName')", exception.Message ); } diff --git a/MigrationTool/MigrationTool.csproj b/MigrationTool/MigrationTool.csproj index 981647a..e6006d6 100644 --- a/MigrationTool/MigrationTool.csproj +++ b/MigrationTool/MigrationTool.csproj @@ -1,4 +1,4 @@ - + Exe @@ -6,11 +6,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + + + diff --git a/SeedDatabase/SeedDatabase.csproj b/SeedDatabase/SeedDatabase.csproj index e051180..1ad4e50 100644 --- a/SeedDatabase/SeedDatabase.csproj +++ b/SeedDatabase/SeedDatabase.csproj @@ -1,4 +1,4 @@ - + Exe @@ -6,7 +6,7 @@ - + diff --git a/Web.Tests/Web.Tests.csproj b/Web.Tests/Web.Tests.csproj index 2af2070..6621d0a 100644 --- a/Web.Tests/Web.Tests.csproj +++ b/Web.Tests/Web.Tests.csproj @@ -1,18 +1,18 @@ - netcoreapp3.1 + net8.0 false - - - - - - + + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive