Search code examples
c#devexpressxpo

Get data from old column in DevExpress XPO


I'm trying to develop a migration system for when the database changes. I'm using DevExpress XPO as my ORM so that I can target multiple database types.

For column additions, the ORM works fine - but when a column is removed it's a little more problematic.

The ORM doesn't remove columns from the database when it updates the schema - this is fine. However, so that I can migrate that data I'm looking to get the data from the column that still exists, but not on my object model.

I know that I could run a raw query over the connection, but that means targeting SQL against a specific database type - which is what I wanted to avoid while using this ORM.

I have been running into a brick wall trying to figure out how to get at this data, so I'm turning to the community for help. Any ideas?


Solution

  • You can do without your object model and generate temporary one based on the existing database for migration purposes. XPO has built-in capabilities to discover the database schema and build the persistent model dynamically. This article describes how to use these capabilities: How to create persistent metadata on the fly and load data from an arbitrary table