-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for multiple databases in the same model #4898
Comments
@anpete will help with guidance on this one |
|
This is very usefull. Small question about linq API. Will it looks like this?
If so this information probably should be added as extension to For the configuration hint (nolock etc) it probably should be separated in different issue. Any thoughts on this? |
A few more points:
Since there are so many different use cases there should be a hierarchy of location configuation:
For each of these levels I can present you a real-world use case that I have had... If that hierarchy is properly document I don't think it's hard to understand or hard to work with. Is there not an issue tracking table hints such as NOLOCK? There should be. It's important. Surely, the team is tracking it internally. |
@GSPP the use case is pretty clear here. |
I'm not sure if it falls into this category (if not, I'll open a new issue - let me know), but the ability for a single database to have a different table per tenant for the same entity would be good, too. Using the example above, it'd be like select *
from [Orders-Tenant1234] o
join [Products] p on ... Master/shared table for some things, tenant-specific table for others. |
You mean something like have different order table per tenant? |
@laskoviymishka Exactly. Rather than partition by database as noted in the earlier example, partition by table in a single database. (I'd like EF to be able to support that. I have a situation like this right now.) |
As far as I know there is limitation for tables count in azure. It may be not so scalable as it looks :) |
Maybe I'm not hosting in Azure. Or using SQL Server. Point being, the ability to have dynamic table names for an entity seems just as interesting to me as having different databases. If this isn't the right place to note that, like I said, I'm happy to start a different issue. It just seemed like similar concerns - the ability to dynamically change where an entity comes from. |
It may have sense |
@tillig this is absolutely part of this issue (at least the part that's by me and was merged into this one). |
Duplicate of #4019 |
@rowanmiller this ticket goes far beyond the other ticket. The other ticket is about statically specifying a database name. This ticket includes dynamic options. If you want to deduplicate I suggest closing the other way around. |
Good call! I think this is important. |
Given that this issue ended up being about a couple of features, we decided to track them separately:
Neither of these are things we are planning to tackle right away, so they are both on the backlog for the moment. |
Any update. How can one use one entity model to connect multiple database provider like mssql, mysql,oracle ,mongodb etc . Found this but not helpful https://www.codeproject.com/Articles/82017/Preparing-an-Entity-Framework-model-for-multi-prov https://www.codeproject.com/Tips/1062375/Entity-Framework-Multi-DB-Support |
@narendrasinghrathore This issue is about accessing multiple databases of the same kind--for example, multiple SQL Server databases. It's not about different types of databases. You seem to be wanting to access different types of database using the same model. There are several dimensions to this question, so it's hard to give an answer here. I would suggest either opening a new issue explaining clearly what it is you need to do, or perhaps doing the same thing but in a Stack Overflow question--you'll get more knowledgeable eyes on it on Stack Overflow. Finally, keep in mind this GitHub repo is for EF Core. The articles you referenced are for earlier versions of EF, for which the best place to log issues is https://github.com/aspnet/EntityFramework6 |
@ajcvickers Thanks, |
Issue based on #4019 and PR #4672
It nice to have a feature to access multiple database from same model context.
This feature pretty massive. We need to modify following areas:
There are still some open design questions that needs to be resolved:
So we could not implement data annotation mapping to different database. There is a possible solution by introducing additional attribute for this need (like DatabaseAttribute) with single proprte Name. In this case usage could be fairly simple
Also there is should be modelBuilder interface to setup database catalogue manually. Something like this:
For such models we should generate additional catalogue prefix for
FROM
andJOIN
statements.There is couple possible solutions:
The text was updated successfully, but these errors were encountered: