As we all know Q1 introduced a complete new face of OpenAccess ORM. That of course brought some uncertainties between our older customers that had already built their projects based on models generated by the Reverse Mapping Wizard. Well in Q2 amongst all the other goodies, we are introducing a new Upgrade Model Tool which is targeted for older projects which are still in the phase of development. What is the idea behind it - basically it converts all of your persistent classes into one Entity Diagram where you can continue working with your domain model in this great Visual Designer UI.
How can you start it? The new OpenAccess menu has a new command called "Convert To Domain Model". It is only available for execution if your currently selected project has been previously "Enabled" by the Enable Project Wizard
After starting the tool, on the left side of the form, you can see all of the files in your project that will go through some change by the upgrade tool. On the right side panel, there is a description about the change that the selected file will go through:
So all that is left is just clicking the "Convert" button and your project has a completely new look and your old code is still running.
The Visual Designer generates a context which is the entry point for the new OpenAccess API in the runtime. However if you have your code based on IObjectScope and use the usual approach for initializing it with an ObjectScopeProvider, do not have worries, the code will continue working as the OpenAccess Upgrade Tool injects few lines of code in your ObjectScopeProvider class that take care for just that. Take a look at the implementation of the Database() method:
static public Database Database() { if (theObjectScopeProvider1 == null) theObjectScopeProvider1 = new ObjectScopeProvider1(); if (theObjectScopeProvider1.myDatabase == null) { NorthwindEntityDiagrams context = new NorthwindEntityDiagrams(); MetadataContainer metadata = context.Metadata; BackendConfiguration backendConfiguration = NorthwindEntityDiagrams.GetBackendConfiguration(); context.Dispose(); theObjectScopeProvider1.myDatabase = Telerik.OpenAccess.Database.Get("MyDatabaseConnection", backendConfiguration, metadata); } return theObjectScopeProvider1.myDatabase; }
The important thing here is that if you still need to use the IObjectScope API, you have to initialize the Database objects with the new overload of the Database.Get() method that takes a MetadataContainer as an argument. And the easiest way to get one is to take it from the generated OpenAccessContext class. This could really be useful if you update your own code disregarding the use of the ObjectScopeProvider helper class.
So, as you can see, it is really easy to migrate your project developed with older OpenAccess version to the latest and greatest one, but have in mind that this is not obligatory. Even though we have completely new look and feel of the product it is still possible to continue your development with our Q2 version and still use the known Enable project, Reverse Mapping wizard etc. You can achieve that with even fewer steps which are described in this post.