Dynamic schema selection from configuration.. possible?

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
NMH
Posts: 9
Joined: Fri 07 Dec 2012 16:40

Dynamic schema selection from configuration.. possible?

Post by NMH » Fri 08 Feb 2013 20:21

I am attempting to use the LinqConnect template for my Oracle entity model but the schema that it will be operating against changes from environment to environment.

Is it possible to specify this Schema value via a configuration? I don't have any problem with writing the code into the custom template, I just want to make sure that the functionality does not already exist somewhere before I start hacking on it.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Dynamic schema selection from configuration.. possible?

Post by MariiaI » Mon 11 Feb 2013 13:19

You could try disabling the schema name in your model. To do this:
- double-click on the diagram canvas to open Model Settings;
- clear the "Preserve schema name in storage" check box;
- save changes.

After these steps, you have to re-create your model in order to changes become effective for all entity classes.
Use "Update Model from Database" wizard with the selected "Recreate Model" option.
In this case queries will be executed to the schema, which is specified in the connection string.

If it isn't what you mean, please specify your question in mode details.

NMH
Posts: 9
Joined: Fri 07 Dec 2012 16:40

Re: Dynamic schema selection from configuration.. possible?

Post by NMH » Mon 11 Feb 2013 20:29

MariiaI wrote:You could try disabling the schema name in your model. To do this:
- double-click on the diagram canvas to open Model Settings;
- clear the "Preserve schema name in storage" check box;
- save changes.

After these steps, you have to re-create your model in order to changes become effective for all entity classes.
Use "Update Model from Database" wizard with the selected "Recreate Model" option.
In this case queries will be executed to the schema, which is specified in the connection string.

If it isn't what you mean, please specify your question in mode details.
This was my first thought however, we're in a situation where in lower environments our development accounts own our objects. In upper environments we use an application account which has permissions to but does not own the objects we're trying to access. That's why it seems the best solution is to specify the schema in configuration.

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Dynamic schema selection from configuration.. possible?

Post by MariiaI » Tue 12 Feb 2013 11:28

If you know the names of all schemas, which you are going to use, we recommend you to provide different mapping information for the context instances. For example, you can do this via the XML mapping.

In this case you should do the following:
1. Change "Mapping Mode" in model settings to "File". Entity Developer will generate the mapping file ([YourModelName].xml) for the schema you are using.
2. Make a copy of the generated xml file.
3. Change connection in the Database Explorer to the necessary one.
4. Check the Target Server in Model Settings -> Synchronization -> Mapping. It must be set to the one that you are using (i.e., to Oracle Server of the proper version).
5. Run the Update Database Wizard to create the database objects, if necessary; select the 'Regenerate Storage' option at the first step of the wizard.
6. Save changes and open the mapping file. Now it should contain mapping for the new schema.
7. Save this new mapping file somewhere and repeat the previous steps for other schemas, if necessary.

For more information about using XML mapping, see http://www.devart.com/linqconnect/docs/POCO.html or read the corresponding article in the LinqConnect documentation (Concepts->Mapping->Mapping Kinds->XML Mapping)

Post Reply