Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all articles
Browse latest Browse all 7205

How to prevent altering the legacy database schema when creating an XAF application.

$
0
0

Scenario
Sometimes our customers want to connect their XAF applications to legacy databases, but they often have strong restrictions, which disallow making any changes in the legacy database schema, i.e. adding new tables, new columns. This is bad, because XAF creates the ModuleInfo table to use an application's version for internal purposes. XPO itself can add the XPObjectType table to correctly manage table hierarchies when one persistent object inherits another one, for example (in case of plain tables the XPObjectType table is not necessary). Usually, legacy databases contain plain tables that can be mapped to one persistent object. So, the XPObjectType table is not necessary in such scenarios. One problem still remains: it is the additional ModuleInfo table added by XAF itself.
This example shows how to use an approach from the Database: How to show Business Classes from several databases in a XAF application KB to move the ModuleInfo and XPObjectType tables into a temporary database.

Steps to implement

1. In YourSolutionName.Module project create a custom IDataStore implementation as shown in the WinWebSolution.Module\XpoDataStoreProxy.xx file;

2. In YourSolutionName.Module project create a custom IXpoDataStoreProviderimplementation as shown in the WinWebSolution.Module\XpoDataStoreProxyProvider.xx file;


3. In YourSolutionName.Module project locate the ModuleBase descendant and modify it as shown in the WinWebSolution.Module\Module.xx file;

4. Define connection strings under the <connectionStrings> element in the configuration files of your WinForms and ASP.NET executable projects as shown in the WinWebSolution.Win\App.config and WinWebSolution.Win\Web.config files.

IMPORTANT NOTES
Take special note that the approach shown here is intended for plain database tables (no inheritance between your persistent objects). The classes you added violate this requirement, and so the exception occurs as expected because it's impossible to perform a query between two different databases. Also, you can place additional information in a separate database and access it in your primary database with the help of the "partitioned views" feature of the SQLServer. See "CREATE VIEW" at http://msdn.microsoft.com/en-us/library/aa258253(SQL.80).aspx

Alternatively, you can use a solution from the How to: Use both Entity Framework and XPO in a Single Application help article, which seems to be the easiest here.


Viewing all articles
Browse latest Browse all 7205

Trending Articles