abp icon indicating copy to clipboard operation
abp copied to clipboard

How to use multiple databases in a single project?

Open anaya-upadhyay opened this issue 6 years ago • 6 comments

Hi there, I've created the application using the template from abp.io with Angular and EntityFrameworkCore with MySQL as database.

I have this scenario - a. There are 3 different databases. First, Second and Third. b. Second is a database created for Hangfire implementation. c. I need to update a few tables from First Database to Third Database using the Hangfire.

How to implement this?

Please provide any idea regarding this.

anaya-upadhyay avatar May 21 '20 12:05 anaya-upadhyay

You can check the documentation first. https://docs.abp.io/en/abp/latest/Connection-Strings https://docs.abp.io/en/abp/latest/Entity-Framework-Core

maliming avatar May 21 '20 12:05 maliming

@maliming It means I have to create another module for using another database for the same project.

Can you please clarify the following: I have a first module using the first database. I created another module for the second database. How can I implement the repositories from the models in the second database to the first one?

anaya-upadhyay avatar May 24 '20 08:05 anaya-upadhyay

pls do as the best practice if you want to use abp vnext! what is best practice pls see https://docs.abp.io/zh-Hans/abp/latest

wjkhappy14 avatar May 25 '20 08:05 wjkhappy14

@anaya-upadhyay Check this #2139 issue, the last one comment works for me.
But you must pay attention to that the first line in Configure method is not Generic options.UseXxx() , the following is Generic options.UseXxx<YourAnotherDbContext>().

I think the first line without a generic parameter configures for the default dbprovider used by abp modules, and the others configure for the special dbContext type as a generic parameter.

zhchlmm avatar Jun 22 '20 08:06 zhchlmm

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] avatar Aug 21 '20 14:08 stale[bot]

Take a look at : https://github.com/abpframework/abp/issues/4251 Maybe it helps you

aelhadi avatar Oct 31 '20 12:10 aelhadi