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

How to: Expose OpenAccessContext via ServiceStack

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.

Services Wizard can help you generate ServiceStack services for the persistent classes in your model. This topic will guide you through the process.

Suppose you already have a web application project in your solution, and a class library that holds your Data Access model. If you do not, you can create such a structure with the help of the Telerik Data Access Web Application project template.

To create the web services, you need to:

  1. Right-click the .rlinq file in Solution Explorer and select Add Telerik Data Access Service...

    If you don't have a .rlinq file, e.g. you have a Fluent Model project, you can start the wizard by using the context menu of the Web Application where the service will reside.

  2. This will bring up the Service Wizard. The first page of the wizard is the Select Source and Output dialog. From the Select context drop-down select your domain context. By default, it is named EntitiesModel. From the Host in Project drop-down select the project that will contain the output. In this example, the project that contains the domain model and the project that will contain the generated controllers are the same - WebApplication. Check the Use Existing Project option and select your web project.

  3. Click Next to continue. The Select Service Type dialog appears. You need to select the service type. Select ServiceStack Service.

  4. Click Next. In the Service Configuration dialog, select for which entities the wizard should generate services. By default all entities are selected. Also you have the option to specify what CUD operations can be performed on the selected entities. More special is the case when your domain model contains views. You can use the views only for read operations. By default, if your view doesn't have a primary key, the corresponding entry in Service Wizard is disabled. If you want to expose a view through a service, you need to specify a primary key in Visual Designer.

  5. Once all selections are done, click Next to proceed. In the Preview dialog, review all changes that will be done in your project.

  6. Click Finish to generate the services.

  7. To test the generated service layer, you need to set the hosting web application as a startup project and to press F5.

    ServiceStack allows the free usage of up to 10 service methods. If your service layer will contain a higher number of methods, you need to provide a ServiceStack license key in the Web.config file of the hosting web application.

See Also

To see what is the outcome of the service generation, check out the Service Generation Outcome topic.