Page 1 of 1

Connection.Database property is empty

Posted: Wed 22 Dec 2010 14:46
by labate
Hello,

I noticed that the property Connection.Database of my context is always empty.

The documentation says "Gets the name of the current database after a connection is opened, or the database name specified in the connection string before the connection is opened."

In fact, when my connection is closed, ctx.Connection.Database is empty.
After a ctx.Connection.Open(), this property is still empty.

I would like to get the current database type (Oracle, SQLServer) in order to execute a special store command. With this Database property always empty, I have no way to do that, except by inspecting the ServerVersion property that is equals to "Oracle Database 11g Release 11.2.0.1.0 - 64bit Production", but I would like to find a better solution.

Posted: Wed 22 Dec 2010 16:44
by AndreyR
I have just made a couple of tests, SQL Server-based data models do not set the EntityConnection.Database property as well.
We will investigate the possibility to add the requested functionality.
I will let you know about the results of our investigation.

Posted: Wed 22 Dec 2010 17:39
by labate
Thank you, keep me informed.

Posted: Fri 24 Dec 2010 09:49
by AndreyR
There is no way to override the default behaviour of the EntityConnection.Database property.
I recommend you the following way to check instead:

Code: Select all

if((ctx.Connection as EntityConnection).StoreConnection.GetType().Name == "OracleConnection")