We created a microservice solution using the following command:
abp new ZW -t microservice-pro -u angular
Then we added a microservice-service to the solution using:
abp new CompanyService -t microservice-service-pro
Now I want to use MongoDB on the newly added µservice-service and keep using the ef core for the main solution for identity and other related features.
I've already tried to add mongodb into CompanyService
µservice-service. I am getting issues with
Please let me know if this is possible, and if so is there any best practice?
Thank you
- ABP Framework version: v4.3
- UI type: Angular
- DB provider: EF Core & MongoDB
39 Answer(s)
-
0
Hello,
You need to replace .EntityFrameworkCore project with .MongoDB project and update the related dependencies.
To use auto-migration, update connection string located in your microservice host.api appsettings.json. Check Database Migrations docs to understand which connection strings are used for.
-
0
Hi I added the MongoDB project and removed the EntityFameworkCore project. I am still facing the same problem. It looks like when I add mongo reference its trying to use everything associated with the project like saas and admin to work with mongo. I only want to use mongo for CRUD purposes of an entity.
Please help Tx.
-
0
Hi,
Update connection string to
mongodb://localhost:27017/ZW_Administration
-
0
I dont want to use admin and saas in mongo. I want to use it as sql as they're part of the main microservice sln called 'ZW' which uses efcore. My microservice "CompanyService" service should use mongo only for crud on the entities in that.
As explained in the first post:
ZW - name of main microservice solution uses angular and efcore ZW.CompanyService - name of the microservice service project which uses angular and mongo.
-
0
As far as I understand, you have some misconfiguration for microservices:
Infrastructural Microservices:
AdministrationService: If you want to have Sql-Server db, must have AdministrationService.EntityFrameworkCore project with a sql-server connection string which is default when you download template. IdentityService: If you want to have Sql-Server db, must have IdentityService.EntityFrameworkCore project with a sql-server connection string which is default when you download template. SaasService: If you want to have Sql-Server db, must have SaasService.EntityFrameworkCore project with a sql-server connection string which is default when you download template.
If you want to change infrastructural microservice databases, you need to create a new .MongoDB project and replace it with .EntityFrameworkCore project with required module mongodb references.
New Microservice:
CompanyService : If you want to use MongoDB, must have CompanyService.MongoDB project with a mongodb connection string like
mongodb://localhost:27017/ZW_CompanyService
.Same as here, create a new CompanyService.MongoDB (or whatever you want to name it) and update connection strings. Check database-migrations docs for more information.
-
0
This question has been automatically marked as stale because it has not had recent activity.
-
0
Hi,
the microservice template has gotten better by leaps and bounds since the last time I raised this issue. Now we can add a service to a microservice solution by using:
abp new OrderService -t microservice-service-pro
This creates a solution with efcore.
Do we have a similar command, say:
abp new ProductService -t microservice-service-pro -d mongodb
That allows us to add a service that uses mongodb for storing its domain entities? This service will be using the efcore backing given by the microservice for identity, admin, saas etc.
The above command is only for reference, it doesn't generate a project with mongodb.
Now to the question.
Is there a command to straight away generate a microservice service that uses mongodb? If not, is there any references that we can check to see how to implement one? Could you please let us know how to achieve this?
Thank you :)
-
0
Hi, any updates please.
-
0
helooo anybody there?
-
0
Hi,
Is there a command to straight away generate a microservice service that uses mongodb?
CLI does not support
-d
arg for microservice template, but I think this is a useful feature, we will consider support it.If not, is there any references that we can check to see how to implement one? Could you please let us know how to achieve this?
No document yet, you can create an app template with ef core and other template with mongod to compare.
-
0
Hi Liang,
I am already doing it, I'll keep the thread active with errors that I'll run into on the way ;) Btw it'd be good to have something to look into while we do this. May I suggest you that from your next iteration of microservice template, you could include a microservice service that uses mongo as well? Right now we have product-service that uses ef core, why not have one more service that uses mongo. This would be highly helpful.
-
0
Hi Neozzz,
I'm trying to achieve the same thing as you but I'm still trying to figure things out. It will be great if you could share how you change the new microservice to use MongoDB while the other microservices are still using EF Core.
Thanks!
-
0
Hi Vincent,
we as users of the platform wouldn't know 100% how the platform works and hence it's really difficult for us to do this task, I figure. However I was trying it out, but let's hope with the help of the abp support team we can find some solution. If we manage to do that, I'll put it in abp community and share it :)
-
0
Hi Liang,
I have updated the project with mongodb. i havent integrated it with the main microservice solution. Could you please take a look at the mongodb integration? Meanwhile, could you please check error with gateway that i mentioned in ticket #2065? Both are in the same repo.
Looking forward to your reply :)
-
0
Hi,
We have no plan support MongoDB for microservice template yet. but I will give you some suggestions to switch to MongoDB.
-
0
Hi,
There are many steps to change to mongodb. so I made an example, will send to your email, you can check it.
-
0
Thanks a lot Liang.
Waiting for your mail :)
-
0
Hi Liang, if you don't mind, could you email me the changes needed for mongodb as well?
Thanks!
-
0
Okay, please email me shiwei.liang@volosoft.com.
Also, We will write a guide to help switch to MongoDB, I will reply when the guide is complete.
-
0
-
0
Hi,
Make sure your MongoDB supports transcation.
Or disable transactions:
Configure<AbpUnitOfWorkDefaultOptions>(options => { options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; });
-
0
Thanks Liang!
Thank you for the solution, which uses mongo for all the db requirements. I tried to put a mongo project into the main microservice solution that uses efcore for the admin, saas and other common operations. I am getting some errors from the database migration event handler. Could you please guide me on how to resolve this?
I'll share the repo access with you, or if you'd like to take a look at this remotely, please let me know.
Thanks for the help :)
-
0
hi liang, kind reminder.
-
0
hi,
please update.