System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')
at MongoDB.Driver.Core.Misc.Ensure.IsNotNull[T](T value, String paramName)
at MongoDB.Driver.Core.Configuration.ConnectionString..ctor(String connectionString, Boolean isInternalRepresentation, IDnsResolver dnsResolver)
at MongoDB.Driver.Core.Configuration.ConnectionString..ctor(String connectionString)
at MongoDB.Driver.MongoUrlBuilder.Parse(String url)
at MongoDB.Driver.MongoUrlBuilder..ctor(String url)
at MongoDB.Driver.MongoUrl..ctor(String url)
at Volo.Abp.Uow.MongoDB.UnitOfWorkMongoDbContextProvider`1.GetDbContextAsync(CancellationToken cancellationToken)
at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository`2.GetMongoQueryableAsync[TOtherEntity](CancellationToken cancellationToken)
at Volo.Abp.Identity.MongoDB.MongoIdentityClaimTypeRepository.AnyAsync(String name, Nullable`1 ignoredId, CancellationToken cancellationToken)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at Volo.Abp.IdentityServer.IdentityResources.IdentityResourceDataSeeder.AddClaimTypeIfNotExistsAsync(String claimType)
at Volo.Abp.IdentityServer.IdentityResources.IdentityResourceDataSeeder.CreateStandardResourcesAsync()
at ProjectName.IdentityService.DbMigrations.IdentityServerDataSeeder.SeedAsync() in /Users/jeffb/Projects/projectname/services/identity/src/ProjectName.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs:line 72
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapter.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at ProjectName.IdentityService.DbMigrations.IdentityServiceDataSeeder.SeedAsync(Nullable`1 tenantId, String adminEmail, String adminPassword) in /Users/jeffb/Projects/projectname/services/identity/src/PorjectName.IdentityService.HttpApi.Host/DbMigrations/IdentityServiceDataSeeder.cs:line 64
On Identity Mongo interface:
public interface IIdentityProMongoDbContext : IAbpIdentityMongoDbContext, IAbpMongoDbContext
{
}
public interface IAbpIdentityMongoDbContext : IAbpMongoDbContext
{
IMongoCollection<IdentityUser> Users { get; }
IMongoCollection<IdentityRole> Roles { get; }
IMongoCollection<IdentityClaimType> ClaimTypes { get; }
IMongoCollection<OrganizationUnit> OrganizationUnits { get; }
IMongoCollection<IdentitySecurityLog> SecurityLogs { get; }
IMongoCollection<IdentityLinkUser> LinkUsers { get; }
}
Identity Efcore Interface
public interface IIdentityServerDbContext : IEfCoreDbContext
{
#region ApiResource
DbSet<ApiResource> ApiResources { get; }
DbSet<ApiResourceSecret> ApiResourceSecrets { get; }
DbSet<ApiResourceClaim> ApiResourceClaims { get; }
DbSet<ApiResourceScope> ApiResourceScopes { get; }
DbSet<ApiResourceProperty> ApiResourceProperties { get; }
#endregion
#region ApiScope
DbSet<ApiScope> ApiScopes { get; }
DbSet<ApiScopeClaim> ApiScopeClaims { get; }
DbSet<ApiScopeProperty> ApiScopeProperties { get; }
#endregion
#region IdentityResource
DbSet<IdentityResource> IdentityResources { get; }
DbSet<IdentityResourceClaim> IdentityClaims { get; }
DbSet<IdentityResourceProperty> IdentityResourceProperties { get; }
#endregion
#region Client
DbSet<Client> Clients { get; }
DbSet<ClientGrantType> ClientGrantTypes { get; }
DbSet<ClientRedirectUri> ClientRedirectUris { get; }
DbSet<ClientPostLogoutRedirectUri> ClientPostLogoutRedirectUris { get; }
DbSet<ClientScope> ClientScopes { get; }
DbSet<ClientSecret> ClientSecrets { get; }
DbSet<ClientClaim> ClientClaims { get; }
DbSet<ClientIdPRestriction> ClientIdPRestrictions { get; }
DbSet<ClientCorsOrigin> ClientCorsOrigins { get; }
DbSet<ClientProperty> ClientProperties { get; }
#endregion
DbSet<PersistedGrant> PersistedGrants { get; }
DbSet<DeviceFlowCodes> DeviceFlowCodes { get; }
}
Why are some of those collections missing on the mongo interface?
For example the IdentityService: *.MongoDb based from your example:
//using ...
namespace ProjectName.IdentityService.MongoDb;
[ConnectionStringName(IdentityServiceDbProperties.ConnectionStringName)]
public class IdentityServiceDbContext : AbpMongoDbContext,
IIdentityServiceDbContext,
IIdentityProMongoDbContext,
IAbpIdentityServerMongoDbContext
{
public IMongoCollection<IdentityUser> Users { get; }
public IMongoCollection<IdentityRole> Roles { get; }
public IMongoCollection<IdentityClaimType> ClaimTypes { get; }
public IMongoCollection<OrganizationUnit> OrganizationUnits { get; }
public IMongoCollection<IdentitySecurityLog> SecurityLogs { get; }
public IMongoCollection<IdentityLinkUser> LinkUsers { get; }
public IMongoCollection<ApiResource> ApiResources { get; }
public IMongoCollection<ApiScope> ApiScopes { get; }
public IMongoCollection<Client> Clients { get; }
public IMongoCollection<IdentityResource> IdentityResources { get; }
public IMongoCollection<PersistedGrant> PersistedGrants { get; }
public IMongoCollection<DeviceFlowCodes> DeviceFlowCodes { get; }
//Create Model
}
On EFCore:
//using ...
namespace ProjectName.IdentityService.EntityFramework;
[ConnectionStringName(IdentityServiceDbProperties.ConnectionStringName)]
public class IdentityServiceDbContext : AbpDbContext<IdentityServiceDbContext>, IIdentityDbContext, IIdentityServerDbContext
{
public DbSet<IdentityUser> Users { get; set; }
public DbSet<IdentityRole> Roles { get; set; }
public DbSet<IdentityClaimType> ClaimTypes { get; set; }
public DbSet<OrganizationUnit> OrganizationUnits { get; set; }
public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }
public DbSet<IdentityLinkUser> LinkUsers { get; set; }
public DbSet<ApiResource> ApiResources { get; set; }
public DbSet<ApiResourceSecret> ApiResourceSecrets { get; set; }
public DbSet<ApiResourceClaim> ApiResourceClaims { get; set; }
public DbSet<ApiResourceScope> ApiResourceScopes { get; set; }
public DbSet<ApiResourceProperty> ApiResourceProperties { get; set; }
public DbSet<ApiScope> ApiScopes { get; set; }
public DbSet<ApiScopeClaim> ApiScopeClaims { get; set; }
public DbSet<ApiScopeProperty> ApiScopeProperties { get; set; }
public DbSet<IdentityResource> IdentityResources { get; set; }
public DbSet<IdentityResourceClaim> IdentityClaims { get; set; }
public DbSet<IdentityResourceProperty> IdentityResourceProperties { get; set; }
public DbSet<Client> Clients { get; set; }
public DbSet<ClientGrantType> ClientGrantTypes { get; set; }
public DbSet<ClientRedirectUri> ClientRedirectUris { get; set; }
public DbSet<ClientPostLogoutRedirectUri> ClientPostLogoutRedirectUris { get; set; }
public DbSet<ClientScope> ClientScopes { get; set; }
public DbSet<ClientSecret> ClientSecrets { get; set; }
public DbSet<ClientClaim> ClientClaims { get; set; }
public DbSet<ClientIdPRestriction> ClientIdPRestrictions { get; set; }
public DbSet<ClientCorsOrigin> ClientCorsOrigins { get; set; }
public DbSet<ClientProperty> ClientProperties { get; set; }
public DbSet<PersistedGrant> PersistedGrants { get; set; }
public DbSet<DeviceFlowCodes> DeviceFlowCodes { get; set; }
// Constructor
// OnModelCreating
}
You can see there are collections that are not on the mongodbcontext. I can't seem to find interface for mongo that has the same required collections from Volo.Abp.IdentityServer.EntityFrameworkCore.IIdentityServerDbContext
One more related question, why do there are some collections missing on mongodb interface over efcore? e.g. IPaymentDbContext
has DbSet<GatewayPlan> GatewayPlans { get; }
but GatewayPlans
mongo collection is not present on IPaymentMongoDbContext
?
Same with some interface collections on IdentityServiceDbContext
over IdentityServiceDbContext
.
Oh I see, that helps. Thanks a lot!
Hi, gterdem thanks for the response. How about this one, I see IPermissionManagementDbContext
inherits IEfCoreDbContext
and also the others.
Q1: What are the existing interface for MongoDB that is equivalent to IPermissionManagementDbContext
, ISettingManagementDbContext
, etc.. that inherits IAbpMongoDbContext
?
Q2: The model builder configuration here are from Volo.Abp.*.EntityFrameworkCore
namespace, are there also ones equivalent for MongoDB?
using Microsoft.EntityFrameworkCore;
using Volo.Abp.AuditLogging;
using Volo.Abp.AuditLogging.EntityFrameworkCore;
using Volo.Abp.BlobStoring.Database;
using Volo.Abp.BlobStoring.Database.EntityFrameworkCore;
using Volo.Abp.Data;
using Volo.Abp.EntityFrameworkCore;
using Volo.Abp.FeatureManagement;
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
using Volo.Abp.LanguageManagement;
using Volo.Abp.LanguageManagement.EntityFrameworkCore;
using Volo.Abp.PermissionManagement;
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
using Volo.Abp.SettingManagement;
using Volo.Abp.SettingManagement.EntityFrameworkCore;
using Volo.Abp.TextTemplateManagement.EntityFrameworkCore;
using Volo.Abp.TextTemplateManagement.TextTemplates;
namespace ProjectName.AdministrationService.EntityFrameworkCore;
[ConnectionStringName(AdministrationServiceDbProperties.ConnectionStringName)]
public class AdministrationServiceDbContext : AbpDbContext<AdministrationServiceDbContext>,
IPermissionManagementDbContext,
ISettingManagementDbContext,
IFeatureManagementDbContext,
IAuditLoggingDbContext,
ILanguageManagementDbContext,
ITextTemplateManagementDbContext,
IBlobStoringDbContext
{
public DbSet<PermissionGrant> PermissionGrants { get; set; }
public DbSet<Setting> Settings { get; set; }
public DbSet<FeatureValue> FeatureValues { get; set; }
public DbSet<AuditLog> AuditLogs { get; set; }
public DbSet<Language> Languages { get; set; }
public DbSet<LanguageText> LanguageTexts { get; set; }
public DbSet<TextTemplateContent> TextTemplateContents { get; set; }
public DbSet<DatabaseBlobContainer> BlobContainers { get; set; }
public DbSet<DatabaseBlob> Blobs { get; set; }
public AdministrationServiceDbContext(DbContextOptions<AdministrationServiceDbContext> options)
: base(options)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ConfigurePermissionManagement();
modelBuilder.ConfigureSettingManagement();
modelBuilder.ConfigureFeatureManagement();
modelBuilder.ConfigureAuditLogging();
modelBuilder.ConfigureLanguageManagement();
modelBuilder.ConfigureTextTemplateManagement();
modelBuilder.ConfigureBlobStoring();
}
}
Cheers, Jeff B
Hello, can anyone provide a sample project of changing or using a MongoDB provider for a microservice solution? ABP Suite only offers creating it with an EFCore SqlServer db provider. I understand that there is a documentation guide(https://docs.abp.io/en/commercial/latest/guides/microservice-mongodb) for changing the default into mongo db but it only shows changing the product service. I just want to know how to change also the administration, identity, saas services since its dbcontexts depends on many other module's db context. I'm afraid I might miss something or might not do it on a right way if I do it myself.
Cheers, Jeff