How can Entity Framework detect if it is created from SQL Server or Oracle by code? Is there any property or method which returns the source database type?
Entity Framework knows it from connection being used in DbContext (either from connection string, because it has Provider part or from instance itself directly). You can get the "type" from DbContext.Database.Connection. I.e.:
DbContext.Database.Connection.GetType().Name
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With