In this post we will learn step by step to create WCF Data Service using Telerik Open Access ORM. We will create data model of data from SQL Server and further exposed that as WCF Data Service using Telerik Open Access ORM.
Learn more about Open Access ORM here
We are going to follow step by step approach. To create WCF Data Service follow the steps given below,
Step 1: Create Telerik Web Access Web Application project
After installation of Telerik Open Access ORM you will get Telerik Web Access Web Application project template while creating a new project. Go ahead and create a project selecting Telerik Web Access Web Application project template from Web group
Step 2: Create Domain Model
Next you will be prompted to create Domain Model. Open Access ORM allows you to create domain model from any of the following type of database. If required you can create Empty Domain Model as well.
Let us go ahead and create data model from Microsoft SQL Server. Choose Microsoft SQL Server from drop down and click on the Next.
Step 3: Setup Database connection
In this step you need to set up Database connection. Either you can provide Connection String manually or can create a New Connection. To create new connection click on Add New Connection. You will get window to add new connection. In this window provide database server name and choose database from the dropdown. To test the connection click on Test Connection and after successful testing click on Ok to add a new connection.
Step 4: Setup Database Connection
In this step you need to setup database connection. If you want you can change connection string name. Let us leave it to default and click on the Next.
Step 5: Choose Database Items
In this step you need to choose
- Stored Procedure to create data model.
Let us say we are choosing only one table to create data model. After choosing items click on the next .
Step 6: Define Naming Rules
In this step you can define naming rules of Classes, Fields and Properties if required. Let us leave to default and click on next to proceed further
Step 7: Code Generation Settings
In this step you can configure Code Generation Settings. Let us leave settings to default and click on Finish to generate data model.
Once Data Model is created you will find *.rlinq file added in the project. Click on *.rlinq file to view the data model.
Step 8: Add Open Access Service
By step 7 you have created data model. Now let us go ahead and add WCF Data Service on the created Data Model. For this right click on the project and select Add Open Acccess Service. You will be prompted with Add Open Access Service Wizard. Before adding Open Access Service make sure that once you have built the project.
You need to choose
- Context : Select Context from the drop down
- Project : Use the existing project
Click on the Next after selecting Context and Project.
Step 9: Select Service Type
In this step you need to choose type of Service you want to create. Since we want to create WCF Data Service, let us choose that from the option and click on the next.
Step 10: Choose Entity to expose a part of the Service
In this step we need to choose entity to expose as part of service. Since there is only one entity choose that and click on the Next
In last step you can preview various References being added and changes to config files. Click on Finish to create Service. After WCF Data Service being created you can test that in browser. Run the application and browse to *.svc to test the service in browser.
You should get data of People in browser as below after successful creation of the service.
In this post we learnt to create WCF Data Service using Open Access ORM. I hope you find this post useful. Thanks for reading.