Data Access has been discontinued. Please refer to this page for more information.

Creating a New Telerik® Data Access Web Site

This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.

In this tutorial, you will create a new Web Site project that you can use as a starting point for your application. You are going to use the Telerik Data Access WebSite project template. When you select this template, two projects will be created. The first will be a normal web site project, and the other will hold a domain model. The Telerik Data Access New Domain Model Wizard will run, allowing you to configure the domain model. Once the configuration is complete, a new RLINQ file will be added to the model project.

Creating a New Web Site Project

In this task, you use a Telerik Data Access project template in Microsoft Visual Studio to create a new Web Site that you can use as a starting point.

To Create the Web Site:

  1. Start Visual Studio, on the File menu select New, and then select Web Site.
  2. In the New Web Site dialog box, select Visual Basic or Visual C# as the programming language.
  3. In the Templates pane, select Telerik Data Access WebSite.

    The Telerik Data Access Web Application template is available only in Visual Studio 2010/2012 for applications that use .NET version 4/4.5.

  4. Type CarRentWebSite as the name of the web site as shown on the image below.

  5. Click OK.

  6. Two projects will be created. The first will be a normal web site project named CarRentWebSite. The second project will be an OpenAccessClass Library project named CarRentWebSiteModel.
  7. The New Domain Model Wizard appears automatically. In the Select Domain Model Type screen, select Populate from database. Enter SofiaCarRentalContext for Model name. Click Next to continue.
  8. In the Setup Database Connection screen, create a data connection to the SofiaCarRental database and click Next.
  9. In the Choose Database Items screen, select all tables.
  10. Click Finish to generate your model. Persistent classes are generated for all tables from the SofiaCarRental database. The wizard adds the EntitiesModel.rlinq file to the CarRentWebSiteModel project. Also references to the Telerik.OpenAccess.dll and Telerik.OpenAccess.35.Extensions.dll assemblies are added. And finally, a new config file with the connection string for the SofiaCarRental database is created and added to the CarRentWebSiteModel project.
  11. Now you should have two projects in the CarRentWebSite solution, as it is shown on the snapshot below.

  12. Open the Default.aspx page and delete the predefined content, so you end up with the following:

    <%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master"
       AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    <%@ Page Title="Home Page" Language="VB" MasterPageFile="~/Site.Master"
        AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
    <asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
  13. Open the Site.master and delete the ScriptManager declaration at the beginning of the <body></body> tag. This is required because in the next task, you are going to use a RadScriptManager for the Default.aspx page. And in the same time, only one instance of a ScriptManager can be added to a page. You need to delete the following:

    <asp:ScriptManager runat="server">
           <asp:ScriptReference Name="jquery" />
           <asp:ScriptReference Name="jquery.ui.combined" />
  14. Build the Solution.

  15. The final step is to copy the connection string from the App.config file from the CarRentWebSiteModel project and paste it in the connectionStrings section in the Web.config file from the CarRentWebSite project. The reason for that action is that the CarRentWebSite project is your server project. When you run the application all settings (configurations) are taken from that project. Respectively, the OpenAccessContext will try to retrieve the connection string from the config file in the server project. If such doesn't exist, the initialization of the OpenAccessContext will fail.

    <?xml version="1.0" encoding="utf-8"?>
       <add name="SofiaCarRental21Connection" 
            connectionString="data source=(local);initial catalog=SofiaCarRental21;
                              integrated security=True" 
            providerName="System.Data.SqlClient" />

In this task, you created a new Web Site project by using the Telerik Data Access WebSite project template. Then, you created a new domain model based on the SofiaCarRental database and added it to the CarRentWebSiteModel project. Next, you will start implementing the user interface.