AddDbContext method for DI

Let's then add a TODO and/or a bug for this.

Sent from my Windows Phone
________________________________
From: Arthur Vickers<mailto:notifications@github.com>
Sent: ý10/ý13/ý2014 11:29
To: aspnet/EntityFramework<mailto:EntityFramework@noreply.github.com>
Cc: Diego Vega<mailto:Diego.Vega@microsoft.com>
Subject: Re: [EntityFramework] AddDbContext method for DI (#856)


In src/EntityFramework/DbContext.cs:

> @@ -74,6 +108,25 @@ public DbContext([NotNull] IServiceProvider serviceProvider, [NotNull] DbContext
>              _logger = new LazyRef<ILogger>(() => _configuration.Value.LoggerFactory.Create("DbContext"));
>          }
>
> +        internal static TContext ActivateInstance<TContext>([NotNull] IServiceProvider serviceProvider)
> +            where TContext : DbContext
> +        {
> +            Check.NotNull(serviceProvider, "serviceProvider");
> +
> +            var typeActivator = serviceProvider.GetService<ITypeActivator>();


We don't have a general pattern for elsewhere. We discussed a pattern for logger factories, but it hasn't been implemented. I believe Emil was going to follow up with Lou or whomever else is appropriate as to what the expectations are around how logger factories should be added/chained. That would allow us to make an appropriate call for dealing with no factory being present and allow us to do something to deal with this across the different consumers rather than just for EF.

—
Reply to this email directly or view it on GitHub<https://github.com/aspnet/EntityFramework/pull/856/files#r18786011>.