use IServerStartup for registering DbContextFactory
This commit is contained in:
parent
31f1079dfa
commit
074fcaaa73
|
@ -312,19 +312,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
|||
serviceType = Type.GetType(serviceName);
|
||||
}
|
||||
services.AddTransient(serviceType ?? implementationType, implementationType);
|
||||
|
||||
if (implementationType.BaseType == typeof(DBContextBase))
|
||||
{
|
||||
if (implementationType.Name == "HtmlTextContext")
|
||||
{
|
||||
services.AddDbContextFactory<Oqtane.Modules.HtmlText.Repository.HtmlTextContext>(opt => { }, ServiceLifetime.Transient);
|
||||
}
|
||||
// need a way to call AddDbContextFactory dynamically passing the implementationType
|
||||
//typeof(IServiceCollection)
|
||||
// .GetMethod("AddDbContextFactory")
|
||||
// .MakeGenericMethod(implementationType)
|
||||
// .Invoke(services, new object[] { new DbContextOptionsBuilder(), ServiceLifetime.Scoped });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Oqtane.Infrastructure;
|
||||
|
||||
namespace Oqtane.Modules.HtmlText.Repository
|
||||
{
|
||||
public class HtmlTextDbContextFactory : IServerStartup
|
||||
{
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
public void ConfigureMvc(IMvcBuilder mvcBuilder)
|
||||
{
|
||||
// not implemented
|
||||
}
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddDbContextFactory<HtmlTextContext>(opt => { }, ServiceLifetime.Transient);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user