Page 1 of 1

Is there a way to configure EntitySet Schema at runtime?

Posted: Thu 14 Apr 2011 08:53
by object
We're approaching a production stage of our application that uses dotConnect for Oracle and Entity Framework, and production configuration requirements are different from our development server convention.

Development:
- Everyone uses his own user and schema when working with the database. To achive this we removed schema name from a generated SSDL:



This works fine so users "John" and "Pete" can create their own schemas and the model will use the schema that matches user name.

Production:
- Everyone has to use one dedicated schema, so leaving schema name blank won't work, we have to explicitly set it:



The dilemma is that this has to be compiled right into a model DLL, and once it's there it will no longer work with local develpment environment.

So the question is whether it's possible to assign the schema to an EntitySet at runtime, so we don't need to compile a special production version of the model DLL (this would be a maintenance disaster).

Thanks in advance.

Posted: Fri 15 Apr 2011 15:23
by AndreyR
This problem was discussed here at our forum, for example.
The only difference is that you need to execute the ALTER SESSION SET CURRENT_SCHEMA statement.
Using this code you are able to set the current schema (model should not contain Schema in this case).
The new Beta build (it will be released in a week or two) contains an OracleEntityProviderConfig.Workarounds.IgnoreSchemaName property. If it is set to true, all commands and queries ignore the schema name and use the current schema

Posted: Fri 29 Apr 2011 14:59
by object
Thank you, we have found a workaround by registering aliases in the Oracle database for each user. But "ALTER SESSION" approach will also seem to work.

Best regards

Vagif

Posted: Fri 29 Apr 2011 15:26
by object
BTW, in Mircosoft forum I was advised to have a look at fluent API introduced in EF Code First, and there is a thread in your forum about it:

http://www.devart.com/forums/viewtopic.php?t=20032

Do you think this might help? To make a call like this and specify the schema at runtime:

modelBuilder.Entity().ToTable("MYSCHEMA.EdmMetadata");

Posted: Tue 03 May 2011 12:03
by Shalex
This is correct. But it should be remembered that fluent mapping in Entity Framework 4.1 does not fully supports all capabilities provided by conventional XML-mapping. Thus, within fluent mapping, you can no longer use:
* Stored Procedures
* Compiled queries
* Complex entity splitting
* View pregeneration

So if all objects of the model reside in the same schema, it is better to use this workaround (last post in this topic): http://www.devart.com/forums/viewtopic. ... c&start=15. Be aware that you can change current schema with oracleConnection.ChangeDatabase("SchemaName"); in the latest builds: http://www.devart.com/forums/viewtopic.php?t=17930.

Posted: Tue 03 May 2011 13:14
by object
I see. Thanks a lost for clarification.