Starts in:
2 DAYS
0 HR
31 MIN
38 SEC
Starts in:
2 D
0 H
31 M
38 S
Open Closed

Microservice project to use MongoDB Provider Documentation out of date #6643


User avatar
0
rogercprops created
  • ABP Framework version: Commercial v7.2.0
  • UI Type: N/A
  • Database System: MongoDB
  • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace: N/A
  • Steps to reproduce the issue: N/A

Our solution is built on the Microervice template. We want to create a microservice using MongoDb instead of EF Core for SQL Server. Note this is not for all microservices.

The documentation for changing the database from EF Core to MongoDb is out of date: https://docs.abp.io/en/commercial/7.2/guides/microservice-mongodb

For example: Some of the changes appear to be in the EntityFrameworkCore project and some in the domain project but it's not clear. Making changes in the EntityFrameworkCore project doesn't make sense since it's being replaced by MongDb.

Also, these dont' exist: Remove Migrations folder. Update BookStoreDbMigrationService class to the following: (substitute BookStore with the microservice name)

Since Abp Suite doesn't support selecting the database for the Microservice template I created a project using Abp Suite and the Application template for MongDb. Now I'm trying to translate into the Microservice project structure and am struggling.

Please update the documentation, point me to an accurate solution or tell me I'm mistaken.

Thank you.


6 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    I will update the document

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    https://github.com/abpio/abp-commercial-docs/pull/745

  • User Avatar
    0
    rogercprops created

    Hi,

    I created a new microservice called StaffService From your guide I could not find the following in my solution:

    • Volo.Abp.PermissionManagement.EntityFrameworkCore
    • AbpPermissionManagementEntityFrameworkCoreModule
    • the Migrations folder
    • IStaffServiceDbContext
    • EfCoreStaffRepository
    • CprOnApbDbMigrationService
    • class DatabaseMigrationEventHandlerBase
    • PendingMigrationsCheckerBase

    I get the following errors: StaffServiceEntityFrameworkCoreModule.cs [DependsOn( typeof(AbpMongoDbModule), typeof(StaffServiceDomainModule) )] error: The type or namespace name 'AbpMongoDbModule' could not be found (are you missing a using directive or an assembly reference?)CS0246

    context.Services.AddMongoDbContext<StaffServiceDbContext>(options => error: IServiceCollection' does not contain a definition for 'AddMongoDbContext' and no accessible extension method 'AddMongoDbContext' accepting a first argument of type 'IServiceCollection' could be found (are you missing a using directive or an assembly reference?)CS1061

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Sorry, the documentation may not be clear.

    I created a new microservice called StaffService

    Because it's a new service and an empty service solution, it doesn't have these.

    rror: The type or namespace name 'AbpMongoDbModule' could not be found (are you missing a using directive or an assembly reference?

    You need to install the Volo.Abp.MongoDb package first.

  • User Avatar
    0
    rogercprops created

    Hi,

    You're correct that it's an empty service solution because it was created using the ABP CLI for creating a new micro-service

    Since Abp Suite doesn't allow adding new microservices to an existing solution, what we usually do is create a duplicate solution using Abp Suite and the Application template so it can automatically generate the code shell for the entity(ies). For example calling it CprOnAbp.StaffService. For EF Core it's a fairly straight forward process to copy the appropriate folders and files from the application template to the micro-service template because Abp Suite generates all of the code in a similar structure as abp new [service name] -t microservice-service-pro --no-ui.

    Because the ABP CLI doesn't allow for creation of a microservice using Mongo DB there should be clear instructions on how to change from EF Core to MongoDB.

    Also, the guide seems to be based on all services being MongoDB. IMO, this goes against a micro-service architecture principle where the underlying code and database for each service are independent. We should be able to have a mix of EF Core & MongDB services depending on the use case.

    Having said all that, following the guide and creating a new Microservice solution and updating the product service I was still not able to find:

    • Volo.Abp.PermissionManagement.EntityFrameworkCore
    • AbpPermissionManagementEntityFrameworkCoreModule
    • IProductServiceDbContext
    • PendingMigrationsCheckerBase

    My recommendation for the guide would be to

    • Create a new micro-service in an existing micro-service solution
    • Create a new project for MongoDB and delete the EntityFrameworkCore project. Provide specific code for each file/class in the MongoDB project.
    • Add the steps and code to migrate/seed the data within the service. Would be nice to have the shared dbMigrator do it but not necessary.

    For now, I'll do my best to update the service for MongoDB and I'll be happy to share the steps and code if I'm successful.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    For now, I'll do my best to update the service for MongoDB and I'll be happy to share the steps and code if I'm successful.

    Ok, thank you

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06