-
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
Infrastructure: DatabaseName is only used by tooling and shouldn't be public runtime API #7936
Comments
@xyting The database to use is controlled only by the connection string. The DatabaseName is stored in the model as part of the reverse engineering process, but is otherwise not used. Note for triage: Consider removing sugar API for this annotation if it is only needed by reverse engineering. |
@ajcvickers Thanks. |
Re-opening so we can discuss @ajcvickers's comment in triage. |
Added |
Should do this for 2.0, since it is a breaking change. |
Fixed with PR #8247. |
Good job, thanks! |
@lajones Make it a Scaffolding() one instead is ok if it is only needed by reverse engineering, but, the reason why I test this feature is I want to dynamically change the database name at runtime. That's to say I want support multiple databases/tables sharding (in the same machine, I assume) in the same model. For MySQL, the Schema is the same as database, so for MySQL, I can dynamically change the the Schema to achieve the same purpose. see this implementation |
@bricelam Yes, this is one choice. Right row, I use a DbContextFactory to dynamic create DbContext to achieve different machine multiple databases/tables sharding in the same model. In the same machine, I do not need to recreate the DbContext, I only change the MySQL Schema to archeve the database change (I doesn't study all the ef core code, so maybe I not know the Model cache whether have any performance issues if I dynamic change the MySQL EntityType's Schema). OK, the all for test purpose, I haven't use it in my production. |
Today, I test some ef core features, I assume the
test_db1
andtest_db2
in the same machine:step1: I use database named
test_db1
in connection stringstep2: I change the database name in
OnModelCreating(ModelBuilder modelBuilder)
method like this:step3: I check where the data inserted, in test_db1? or in test_db2?
The result is data inserted into
test_db1
, so, my question is waht's theDatabaseName
property ofRelationalModelAnnotations
used for?The text was updated successfully, but these errors were encountered: