Skip to content
This repository has been archived by the owner on Nov 2, 2018. It is now read-only.

Microsoft.Extensions.DependencyInjection vs Microsoft.Framework.DependencyInjection #306

Closed
wangkanai opened this issue Oct 16, 2015 · 1 comment
Labels

Comments

@wangkanai
Copy link

Hey Guys

I'm getting an inconstancy beta8 when using IServiceCollection, ServiceCollection, AddEntityFramework, & BuildServiceProvider
This is the full code

using System;
using Microsoft.Data.Entity.Infrastructure;
// Beta8
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
// RC
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.DependencyInjection.Abstractions;
using Microsoft.Framework.DependencyInjection.Extensions;

namespace Tumboon.Domain.Functional.Test
{
    public class TestHelper
    {
        protected TestHelper()
        {
        }

        public static TestHelper Instance { get; } = new TestHelper();

        public IServiceProvider CreateServiceProvider(IServiceCollection customService = null)
        {
            return CreateServiceProvider(customService, AddProviderServices);
        }

        private IServiceProvider CreateServiceProvider(IServiceCollection customServices,
            Func<EntityFrameworkServicesBuilder, EntityFrameworkServicesBuilder> addProviderServices)
        {
            var services = new ServiceCollection();
            addProviderServices(services.AddEntityFramework());
            if (customServices != null)
                foreach (var service in customServices)
                {
                    services.Add(service);
                }
            return services.BuildServiceProvider();
        }

        public virtual EntityFrameworkServicesBuilder AddProviderServices(EntityFrameworkServicesBuilder builder)
        {
            return builder.AddInMemoryDatabase();
        }
    }
}
@pranavkm
Copy link
Contributor

This was renamed as part of RC1. See:
aspnet/Announcements#77
#297

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants