Home > Software design >  Entity Framework Core sharing data between databases
Entity Framework Core sharing data between databases

Time:12-21

I'm making application with two instances (maybe more in future). I need to have two mySQL databases (one for each instance of app), both databases will have tables that always will be the same in both databases. On update i will need to update data in both databases or is there any solution to share several tables between databases?

Problem:

There are tables with definitions (same for both apps) like "ItemPrototypes" and with objects like "Items" I waoner if it is possible to share ItemPrototypes beetwen apps. and tables

CodePudding user response:

What you describe looks more like a microservice in the sense that what is "common" in all the instances should be kept somewhere else (a microservice) for example. Otherwise you will face serious problems with updating and synchronizing your data among all the instances you deploy. For now, as you said, it's only two, but what will happen when there are 5 or more instances? Imagine you need to update all of them. Whereas having a service that you use to pull data is more easy to use and maintain. Yes you will have your database data decentralized which will bring complexity in understanding it, but it is an option anyway.

CodePudding user response:

The canonical solution is to put the shared data in a separate database and either reference is directly from there, or replicate it to each of the two databases for read-only.

  • Related