Hi y'all!

When starting up an application based on DO my domainBuilder does it's work and builds the domain based on the configuration.

After building the domain succesfully, no matter what the UpgradeMode was, I want to set it to Skip (or Validate) because I do not want it to do a Recreate or Perform(Safely) again if that was the UpgradeMode.

This can be done by applying the following (according to the DO documentation):

configuration.UpgradeMode = DomainUpgradeMode.Skip;

This raises an exception saying that the instance is locked. Even after calling:


it remains locked.

What does Xtensive suggest on changing the upgrade mode this way dynamically?

asked Jun 18 '12 at 11:01

Morpheus72's gravatar image


2 Answers:

I resolved it as follows:

Removed the Xtensive configuration sections from my configs; Added the connectionUrl and upgradeMode to appSettings instead; Create a DomaingConfiguration dynamically in my DomainFactory based on the appSettings; And modify the web.config as follows:

 if (domainUpgradeMode != DomainUpgradeMode.Validate.ToString())
            var config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("~") as Configuration;
            config.AppSettings.Settings["upgradeMode"].Value = DomainUpgradeMode.Validate.ToString();

answered Jun 19 '12 at 04:56

Morpheus72's gravatar image


You can use DomainConfiguration.Load to load configuration without building domain, after it is loaded you can adjust your UpgradeMode and then call Domain.Build

(Jun 19 '12 at 06:50) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

Yes I tried that but it does not write it back to the config. Of course you'd have to call the Save method but then the 'Instance is locked' exception is thrown. Updating before building is not what I want and updating after building results in the lock.

(Jun 19 '12 at 07:00) Morpheus72 Morpheus72's gravatar image

You should not write changes to file, but change DomainConfiguration on each domain build for example.

(Jun 19 '12 at 07:41) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

But what if the domainUpgradeMode is set to Recreate? In a web scenario an iisreset or a server fail/reboot would recreate the database if the value Recreate remains in the web.config. Because typically the domain build takes place when starting the application and based on the configuration. If you mean I should override (or ignore) settings in the configuration file... then the whole configuration section doesn't make sense to me in this scenario.

(Jun 19 '12 at 08:01) Morpheus72 Morpheus72's gravatar image

You should not set domainUpgradeMode to Recreate in production server obviously ;-)

(Jun 19 '12 at 08:16) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

Obviously :-) But what about Perform? PerformSafely? After succes I'd still like to switch to Validate.

(Jun 19 '12 at 08:22) Morpheus72 Morpheus72's gravatar image

I would not recommend doing upgrades from IIS process anyway, because IIS can decide to unload your AppDomain. The most reliable approach is to have a separate console tool that just upgrades database and have UpgradeMode set to Validate in web.config i.e. upgrade things on deployment rather than first run.

(Jun 19 '12 at 08:28) Denis Krjuchkov Denis%20Krjuchkov's gravatar image

Yes that seems like the best approach. Thank you so far!

(Jun 19 '12 at 08:36) Morpheus72 Morpheus72's gravatar image

Hello Morpheus72,

you can't change configuration after Domain has been built with it. However, I don't see any reason for that. UpgradeMode only affects actions that occur inside Domain.Build call. Once domain is built UpgradeMode does not matter.

If you want to make upgrade only once for example, you should set UpgradeMode accordingly before Domain.Build call. For regular execution of your application you can set UpgradeMode to Validate before Domain.Build as well.

answered Jun 19 '12 at 04:47

Denis%20Krjuchkov's gravatar image

Denis Krjuchkov

Thanks for your response. I want to modify the UpgradeMode to Validate after the build was succesful. The reason I want to change the upgradeMode is that it could be set to Recreate. If for some reason the application restarts it would result again in building the domain with Recreate which would leed to losing data.

(Jun 19 '12 at 04:51) Morpheus72 Morpheus72's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview


Once you sign in you will be able to subscribe for any updates here



Asked: Jun 18 '12 at 11:01

Seen: 3,317 times

Last updated: Jun 19 '12 at 08:36

powered by OSQA