10
10
using Microsoft . EntityFrameworkCore ;
11
11
using Microsoft . Extensions . Configuration ;
12
12
using Microsoft . Extensions . DependencyInjection ;
13
+ using Microsoft . Extensions . Hosting ;
13
14
using Schema = DataLoaderWithEFCore . GraphApi . Schema ;
14
15
15
16
namespace DataLoaderWithEFCore
@@ -26,31 +27,28 @@ public Startup(IConfiguration configuration)
26
27
// This method gets called by the runtime. Use this method to add services to the container.
27
28
public void ConfigureServices ( IServiceCollection services )
28
29
{
29
- services . AddMvc ( ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_1 ) ;
30
-
31
30
services . AddDbContext < MovieDbContext > ( options =>
32
31
options . UseSqlServer ( Configuration . GetConnectionString ( "DefaultConnection" ) ) ) ;
33
32
34
33
services . AddScoped < IActorRepository , ActorRepository > ( ) ;
35
34
services . AddScoped < ICountryRepository , CountryRepository > ( ) ;
36
35
services . AddScoped < IMovieRepository , MovieRepository > ( ) ;
37
36
38
- services . AddSingleton ( provider => new GraphQLEngine ( )
37
+ services . AddSingleton ( _ => new GraphQLEngine ( )
39
38
. WithFieldResolutionStrategy ( FieldResolutionStrategy . Normal )
40
39
. BuildSchema ( typeof ( SchemaDefinition < Schema . Query , Schema . Mutation > ) ) ) ;
41
40
42
41
services . AddScoped < IDependencyInjector , Injector > ( ) ;
43
- services . AddScoped < IUserContext , UserContext > ( ) ;
44
42
services . AddScoped < Schema . Query > ( ) ;
45
43
services . AddScoped < Schema . Mutation > ( ) ;
46
44
47
45
services . AddScoped < DataLoaderContext > ( ) ;
48
-
49
- Mapper . Initialize ( config => config . AddProfile < Mappings > ( ) ) ;
46
+ services . AddAutoMapper ( typeof ( Mappings ) ) ;
47
+ services . AddControllers ( ) ;
50
48
}
51
49
52
50
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
53
- public void Configure ( IApplicationBuilder app , IHostingEnvironment env )
51
+ public void Configure ( IApplicationBuilder app , IWebHostEnvironment env )
54
52
{
55
53
if ( env . IsDevelopment ( ) )
56
54
{
@@ -62,7 +60,11 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env)
62
60
}
63
61
64
62
app . UseHttpsRedirection ( ) ;
65
- app . UseMvc ( ) ;
63
+ app . UseRouting ( ) ;
64
+ app . UseEndpoints ( configure =>
65
+ {
66
+ configure . MapControllers ( ) ;
67
+ } ) ;
66
68
}
67
69
}
68
70
}
0 commit comments