1+ using F2 . Repository . Demo . Mapper ;
2+ using F2 . Repository . Demo . Models ;
3+ using F2 . Repository . Extensions ;
14using Microsoft . AspNetCore . Builder ;
25using Microsoft . AspNetCore . Hosting ;
36using Microsoft . EntityFrameworkCore ;
47using Microsoft . Extensions . Configuration ;
58using Microsoft . Extensions . DependencyInjection ;
6- using F2 . Repository . Demo . Mapper ;
7- using F2 . Repository . Demo . Models ;
8- using F2 . Repository . Extensions ;
99
1010namespace F2 . Repository . Demo ;
1111
@@ -16,10 +16,10 @@ public class Startup(IConfiguration configuration)
1616 // This method gets called by the runtime. Use this method to add services to the container.
1717 public void ConfigureServices ( IServiceCollection services )
1818 {
19- services . AddHostedService < HostedDbMigrationService < LibraryContext > > ( ) ;
19+ services . AddDatabaseMigration < LibraryContext > ( ) ;
2020
2121 var connectionString = _configuration . GetConnectionString ( "Demo" ) ;
22- services . AddDbContext < LibraryContext > ( config => config . UseNpgsql ( connectionString ) ) ;
22+ services . AddDbContextFactory < LibraryContext > ( config => config . UseNpgsql ( connectionString ) ) ;
2323 services . AddDatabaseScope < LibraryDbScope > ( ) ;
2424
2525 // https://github.com/AutoMapper/AutoMapper.Extensions.Microsoft.DependencyInjection
@@ -30,8 +30,6 @@ public void ConfigureServices(IServiceCollection services)
3030 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
3131 public static void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
3232 {
33- //app.UseDatabaseMigration<LibraryContext>(); // relational databases only
34-
3533 app . UseRouting ( ) ;
3634 app . UseEndpoints ( endpoints => endpoints . MapControllers ( ) ) ;
3735 }
0 commit comments