Пример #1
0
        protected override void ConfigureServices(IServiceCollection services)
        {
            base.ConfigureServices(services);

            services.AddInternalMessageQueue();

            var descriptor = services.FirstOrDefault(x => x.ServiceType == typeof(EntityEventDelegateHandler <OrderMessageHandler>));

            if (descriptor != null)
            {
                services.Remove(descriptor);
                services.AddSingleton(OrderEvents);
            }

            var sp = services.BuildServiceProvider();

            using (var scope = sp.CreateScope())
            {
                var scopedServices = scope.ServiceProvider;
                var db             = scopedServices.GetRequiredService <AdventureContext>();

                db.Database.EnsureCreated();

                RepositoryFixture.Seed(db).Wait();
            }
        }