Telerik blogs

Yesterday Telerik released the Q2 version of OpenAccess ORM as well as the rest of the product line. Yesterday (Part I) I showed you the menus, Data Service Wizard, and new XAML templates. Today I will show you round tripping. Next week I will talk about RIA Services and model first.

OpenAccess Q2’s new LINQ implementation and Visual Designer introduces database round tripping.  Now you can make changes in your model and persist them to your database table. (You always had the ability to make a database schema change and refresh your model.) Let’s see this feature in action. The Model Schema Explorer gives you a view of your mapped entities. If you right click on a table you can choose Edit Table from the context menu to begin editing your entity.

image

This brings up the Edit Table.. dialog where you can insert, edit, and delete columns and set metadata such as data types and nullable.

image

I’ll go ahead add a CurrentCustomer column as a bit to indicate if the customer is current or not. That is all there is to it, so I will right click on my model and select Update Database From Model as shown here.

image

This brings up the Schema Update Wizard. This wizard will allow you to execute the script right away or generate it and save it for later. It will also give you the choice between making an update (alter table) compared to a create (create table).  I’ll decide to make an update and execute it now and click next.

image

After I tell the wizard what table to update the database with (and make sure you have mapped your new column to the model and recompiled the project before running the wizard), you are presented with the script and given the ability to save the script, execute it, or copy it to the clipboard.

image

Being a database geek, I am only going to copy to the clipboard the part of the code that I need, the ALTER TABLE command with the ADD column and run that against my SQL Server. I could let OpenAccess run the code for me, but as I said, I am a database geek and like complete control. The tool gives you whatever level of control you desire. Once you run the TSQL either via the wizard or by hand, the process is complete.

Enjoy!


About the Author

Steve Forte

 sits on the board of several start-ups including Triton Works. Stephen is also the Microsoft Regional Director for the NY Metro region and speaks regularly at industry conferences around the world. He has written several books on application and database development including Programming SQL Server 2008 (MS Press).

Comments

Comments are disabled in preview mode.