Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect dbms type in Entity Framework (Oracle or SQL Server)

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?

like image 873
Mahdi Shahbazi Avatar asked Oct 22 '25 07:10

Mahdi Shahbazi


1 Answers

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
like image 181
cincura.net Avatar answered Oct 24 '25 21:10

cincura.net