|
|
@@ -1,6 +1,8 @@ |
|
|
|
// Copyright (c) .NET Core Community. All rights reserved. |
|
|
|
// Licensed under the MIT License. See License.txt in the project root for license information. |
|
|
|
|
|
|
|
using System; |
|
|
|
using DotNetCore.CAP.Internal; |
|
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using Microsoft.Extensions.Options; |
|
|
@@ -28,7 +30,12 @@ namespace DotNetCore.CAP |
|
|
|
public void Configure(PostgreSqlOptions options) |
|
|
|
{ |
|
|
|
if (options.DbContextType == null) return; |
|
|
|
|
|
|
|
|
|
|
|
if (Helper.IsUsingType<ICapPublisher>(options.DbContextType)) |
|
|
|
{ |
|
|
|
throw new InvalidOperationException("We detected that you are using ICapPublisher in DbContext, please change the configuration to use the storage extension directly to avoid circular references! eg: x.UsePostgreSql()"); |
|
|
|
} |
|
|
|
|
|
|
|
using var scope = _serviceScopeFactory.CreateScope(); |
|
|
|
var provider = scope.ServiceProvider; |
|
|
|
using var dbContext = (DbContext) provider.GetRequiredService(options.DbContextType); |
|
|
|