Specifies if the Application Model cache designed to improve the startup speed and performance is enabled.
true, if the Application Model is cached; otherwise, false.
If your WinForms application starts slowly, you can speed up the startup using the EnableModelCache property. When it is set to true, the Application Model content is cached to a file when the application is first launched, and recovered on subsequent runs. This property has effect in the production environment when the debugger is not attached (see Debugger.IsAttached). By default, EnableModelCache is set to false. To change this property value, add the following code to the Program.cs (Program.vb) file, before the XafApplication.Setup method is called.
As a result, Nodes Generators and Generator Updaters will be executed and the Model.Cache.xafml cache file will be created only when the application is started for the first time. Note that the first startup can take more time than usual. However, the time taken by subsequent startups will be reduced, because the Application Model content will be recovered from the cache. The cache is recreated when the version of any application module is incremented.
The Model.Cache.xafml file name is specified by the static ModelStoreBase.ModelCacheDefaultName field.
When the cache is in use, consider the following.
By default, the Model.Cache.xafml file is located in the application folder. You can change its path using one of the following approaches.
Use the ModelCacheLocation key in the configuration file (App.config).
<appSettings> <!-- ... --> <add key="ModelCacheLocation" value="CurrentUserApplicationDataFolder"/> <!-- ... --> </appSettings>
To determine whether or not the cache file needs to be updated on startup, an XAF application compares the loaded modules versions with versions from the ModulesVersionInfo file. This file stores versions for all modules which were used in the previous application launch. If there are no updated modules, the application loads the cache file; otherwise, the cache file is recreated. Modifying the cache options using the ModelCacheManager class does not enforce an immediate cache update. So, if you see that your customizations have no effect, ensure that at least one of your module versions is incremented, or delete the cache file manually.
By default, the EnableModelCache property has no effect on ASP.NET applications. To enable the cache, overwrite the GetModulesVersionInfoFilePath method in your WebApplication descendant (in the WebApplication.cs (WebApplication.vb) file), and specify the location of the ModulesVersionInfo file that stores the module versions. Then, override the GetModelCacheFileLocationPath method to specify the cache file location.