diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index cd08692..ce26d34 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,6 +10,6 @@ jobs: - name: Setup .NET Core Build Environment uses: actions/setup-dotnet@v1 with: - dotnet-version: '2.2.x' + dotnet-version: '3.1.x' - name: Build package run: dotnet build --configuration Release diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8d4a1fd..7cf81e5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -13,7 +13,7 @@ jobs: - name: Setup .NET Core Build Environment uses: actions/setup-dotnet@v1 with: - dotnet-version: '2.2.x' + dotnet-version: '3.1.x' - name: Build packages run: dotnet build --configuration Release - name: Pack NuGet packages diff --git a/DataTables.NetStandard.Sample/DataTables.NetStandard.Sample.csproj b/DataTables.NetStandard.Sample/DataTables.NetStandard.Sample.csproj index 607c429..3ea7416 100644 --- a/DataTables.NetStandard.Sample/DataTables.NetStandard.Sample.csproj +++ b/DataTables.NetStandard.Sample/DataTables.NetStandard.Sample.csproj @@ -1,34 +1,26 @@ - netcoreapp2.2 - InProcess + netcoreapp3.1 MIT - - - - - - - PreserveNewest - - - - - - + - + + + PreserveNewest + + + diff --git a/DataTables.NetStandard.Sample/Migrations/20190208150135_ScaffoldDatabase.Designer.cs b/DataTables.NetStandard.Sample/Migrations/20190208150135_ScaffoldDatabase.Designer.cs index adc7f0c..cca0585 100644 --- a/DataTables.NetStandard.Sample/Migrations/20190208150135_ScaffoldDatabase.Designer.cs +++ b/DataTables.NetStandard.Sample/Migrations/20190208150135_ScaffoldDatabase.Designer.cs @@ -1,11 +1,9 @@ // using System; -using DataTables.NetStandard.Sample; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataTables.NetStandard.Sample.Migrations { diff --git a/DataTables.NetStandard.Sample/Migrations/20190210154727_AddLocation.Designer.cs b/DataTables.NetStandard.Sample/Migrations/20190210154727_AddLocation.Designer.cs index 151ae38..d988db0 100644 --- a/DataTables.NetStandard.Sample/Migrations/20190210154727_AddLocation.Designer.cs +++ b/DataTables.NetStandard.Sample/Migrations/20190210154727_AddLocation.Designer.cs @@ -1,11 +1,9 @@ // using System; -using DataTables.NetStandard.Sample; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataTables.NetStandard.Sample.Migrations { diff --git a/DataTables.NetStandard.Sample/Migrations/20190215192458_RenameUserToPerson.Designer.cs b/DataTables.NetStandard.Sample/Migrations/20190215192458_RenameUserToPerson.Designer.cs index 1fcb4de..8de91eb 100644 --- a/DataTables.NetStandard.Sample/Migrations/20190215192458_RenameUserToPerson.Designer.cs +++ b/DataTables.NetStandard.Sample/Migrations/20190215192458_RenameUserToPerson.Designer.cs @@ -1,11 +1,9 @@ // using System; -using DataTables.NetStandard.Sample; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataTables.NetStandard.Sample.Migrations { diff --git a/DataTables.NetStandard.Sample/Migrations/20190401124825_AddEmailAddressModel.Designer.cs b/DataTables.NetStandard.Sample/Migrations/20190401124825_AddEmailAddressModel.Designer.cs index 1288cca..fa31fff 100644 --- a/DataTables.NetStandard.Sample/Migrations/20190401124825_AddEmailAddressModel.Designer.cs +++ b/DataTables.NetStandard.Sample/Migrations/20190401124825_AddEmailAddressModel.Designer.cs @@ -1,11 +1,9 @@ // using System; -using DataTables.NetStandard.Sample; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataTables.NetStandard.Sample.Migrations { diff --git a/DataTables.NetStandard.Sample/Migrations/SampleDbContextModelSnapshot.cs b/DataTables.NetStandard.Sample/Migrations/SampleDbContextModelSnapshot.cs index aa0e013..c63d6b1 100644 --- a/DataTables.NetStandard.Sample/Migrations/SampleDbContextModelSnapshot.cs +++ b/DataTables.NetStandard.Sample/Migrations/SampleDbContextModelSnapshot.cs @@ -1,10 +1,8 @@ // using System; -using DataTables.NetStandard.Sample; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Storage.ValueConversion; namespace DataTables.NetStandard.Sample.Migrations { diff --git a/DataTables.NetStandard.Sample/Startup.cs b/DataTables.NetStandard.Sample/Startup.cs index 5ee71bb..48d8713 100644 --- a/DataTables.NetStandard.Sample/Startup.cs +++ b/DataTables.NetStandard.Sample/Startup.cs @@ -4,11 +4,10 @@ using DataTables.NetStandard.TemplateMapper; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; -using Microsoft.AspNetCore.Mvc; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; -using System.Reflection; +using Microsoft.Extensions.Hosting; namespace DataTables.NetStandard.Sample { @@ -25,26 +24,31 @@ public void ConfigureServices(IServiceCollection services) { services.AddDbContext(options => { - options.UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=DataTables.NetStandard.Sample;Trusted_Connection=True;"); + options.UseSqlServer(Configuration.GetConnectionString("Database")); }); - services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); + services.AddControllersWithViews(); services.AddDataTablesTemplateMapper(); services.AddScoped(); + // We need to register custom services we want to use in the mapping profile. + services.AddTransient(); + // Building the service provider early to get the IViewRenderService is a hack that is necessary to get access // to the Razor partial compiler in the DefaultMappingProfile. As the IViewRenderService depends on services // from Microsoft.AspNetCore.Mvc.Razor, it is necessary to configure MVC with services.AddMvc() before // configuring the Mapper like this. - services.AddAutoMapper(m => + services.AddScoped(provider => new MapperConfiguration(config => { - m.AddProfile(new DefaultMappingProfile(services.BuildServiceProvider().GetService())); - }, Assembly.GetAssembly(typeof(DefaultMappingProfile))); + config.AddProfile(new DefaultMappingProfile(provider.GetService())); + }).CreateMapper()); } - public void Configure(IApplicationBuilder app, IHostingEnvironment env) + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, SampleDbContext dbContext) { + dbContext.Database.Migrate(); + if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); @@ -58,11 +62,13 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env) app.UseHttpsRedirection(); app.UseStaticFiles(); - app.UseMvc(routes => + app.UseRouting(); + + app.UseEndpoints(endpoints => { - routes.MapRoute( + endpoints.MapControllerRoute( name: "default", - template: "{controller=Persons}/{action=Index}/{id?}"); + pattern: "{controller=Persons}/{action=Index}/{id?}"); }); } } diff --git a/DataTables.NetStandard.Sample/appsettings.Development.json b/DataTables.NetStandard.Sample/appsettings.Development.json index e203e94..a51458c 100644 --- a/DataTables.NetStandard.Sample/appsettings.Development.json +++ b/DataTables.NetStandard.Sample/appsettings.Development.json @@ -1,4 +1,7 @@ { + "ConnectionStrings": { + "Database": "Server=(localdb)\\mssqllocaldb;Database=DataTables.NetStandard.Sample;Trusted_Connection=True;" + }, "Logging": { "LogLevel": { "Default": "Debug",