As mentioned, Telerik's OpenAccess ORM will be a big part of Sitefinity 4.0. Like RadControls for AJAX and RadControls for Silverlight, OpenAccess be available to Sitefinity developers and used within Sitefinity projects.
Sitefinity is designed to be a web development framework, as well as a CMS. The OpenAccess ORM addresses the crucial data-access layer (DAL) of web applications. Below we'll examine how to install OpenAccess and enable a new project to use OpenAccess.
Install OpenAccess ORM Express
To get started, download OpenAccess ORM Express. This free version of OpenAccess only works with free database servers such as MySQL & SQL Express, but is otherwise fully functional. The full version of OpenAccess ORM supports several additional databases.
Extract the setup files from the downloaded zip file and run the setup.exe file. Click through the installation screens and accept the default options for each step.
Understanding the Basics
OpenAccess is a Visual Studio based tool. Once installed, you'll have a new OpenAccess menu item available in Visual Studio.
OpenAccess allows you to easily persist objects. For example, you can create a Customer class and instruct OpenAccess to persist objects of this type. Once an object is persisted, OpenAccess will handle storing & retrieving these objects from the database.
OpenAccess works by enhancing compiled assemblies. Consequently, you cannot use OpenAccess to persist objects created in your Sitefinity web site's ~/App_Code folder. Objects you wish to persist must be compiled into a separate assembly and then referenced from your Sitefinity web site.
Creating an OpenAccess enabled Project
Because OpenAccess enhances compiled assemblies we need to create a new Visual Studio project for our persistent classes. This project can be enabled for OpenAccess and referenced from our Sitefinity web site.
To create a new project within Visual Studio select File -> New Project. Choose Class Library for the project type and MyClass for the name of your project.
Once the project is created select OpenAccess -> Enable Project to use ORM.
A wizard will open and guide you through the steps needed to enable your project to use OpenAccess.
Press Next for Step 1 of this wizard.
Select Persistent classes and Data access code (DAL) for Step 2 and click Next.
Enter the database settings for your Sitefinity web site in Step 3 and click Next.
Note: If you're using attached SQL Express files with Sitefinity, you will not be able to enter your database settings using this wizard. You can, however, provide the settings later (see section below). Simply accept the default options, for now, and click through the wizard to complete your setup.
Click Finish to complete the OpenAccess setup wizard.
OpenAccess will create an App.config and ObjectScopeProvider1.cs file in your project.
Using OpenAccess with Attached SQL Express Files
This section is only needed if you're using Sitefinity with SQL Express attached files. Otherwise, you may skip the instructions in this section.
We need to tell OpenAccess how to connect to our Sitefinity SQL Express file. To do this select OpenAccess -> Configuration -> Connection Settings from the menu.
Enter the following settings:
Use Integrated Security: True
Database Name: Sitefinity
Server Name: (LOCAL)\SQLEXPRESS
connectionParams: User Instance=True;AttachDbFilename=C:\(full)\(path)\(to)\(Sitefinity)\(website)\App_Data\Sitefinity.mdf
We're Now Ready to Begin
We now have OpenAccess installed and a new Class Library Project enabled to work with OpenAccess. None of the steps above are Sitefinity specific. All we're doing is pointing OpenAccess to an existing database. In our case, this database just happens to be Sitefinity's database.
In my next post we'll use the environment we've setup to create a new persistent object.