Is there a way to configure EntitySet Schema at runtime?

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
object
Posts: 91
Joined: Tue 26 Oct 2010 08:29

Is there a way to configure EntitySet Schema at runtime?

Post by object » Thu 14 Apr 2011 08:53

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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Fri 15 Apr 2011 15:23

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

object
Posts: 91
Joined: Tue 26 Oct 2010 08:29

Post by object » Fri 29 Apr 2011 14:59

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

object
Posts: 91
Joined: Tue 26 Oct 2010 08:29

Post by object » Fri 29 Apr 2011 15:26

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");

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 03 May 2011 12:03

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.

object
Posts: 91
Joined: Tue 26 Oct 2010 08:29

Post by object » Tue 03 May 2011 13:14

I see. Thanks a lost for clarification.

Post Reply