About a month or so ago I showed
on this blog how to connect to MySQL using Telerik's
new LINQ implementation. Today I will show you how to take it one step further
and build an OData service automatically using the Telerik
Data Services Wizard. Just for fun, we will also automatically add a full CRUD
Silverlight application that consumes the OData service. We’ll do this all in 30 seconds!
To get started, you have to download MySQL 5.x and the MySQL Workbench and also, as
my colleague Alexander Filipov at Telerik reminded me, make sure you install the MySQL
.NET Connector, which is available
here. I like to use Northwind, ok it gives me the warm and fuzzies, so I
ran a script to produce Northwind on my MySQL server. There are many ways you can
get Northwind on your MySQL database, here is a helpful
blog to get your started.
Let’s get started! First we will just build our model with Telerik’s new LINQ implementation.
I will repeat the steps I showed off
in this blog post. Start up the Domain Model wizard by right clicking on the project
in Visual Studio (I have a Web project) and select Add|New Item and choose “Telerik
OpenAccess Domain Model” from the new item list.
When the wizard comes up, choose MySQL as your back end and enter in the name of your
saved MySQL connection.
If you don’t have a saved MySQL connection set up in Visual Studio, click on “New
Connection” and enter in the proper connection information. *Note, this is where you
need to have the MySQL .NET connector installed.
After you set your connection to the MySQL database server, you have to choose which
tables to include in your model. Just for fun, I will choose all of them.
Give your model a name, like “NorthwindEntities” and click finish. Now you have a
new Telerik Domain Model named NorthwindModel.rlinq.
Now we are going to use the Telerik
Data Services Wizard to build our OData service endpoint via WCF Data Services
(Astoria) and also automatically build a Silverlight client that will consume this
service. The service has full CRUD capability and the Silverlight application is pretty
basic, but wires up the application to the service and gives you the hooks to extend
We are going to use the “express” version of the Data
Service Wizard and build the service and Silverlight client in less than 30 seconds!
(Note: I showed how to do this using SQL Server here.)
To do this, right click on the NorthwindModel.RLINQ file in the solution explorer
and choose from the context menu: Data Services Wizard|Data Services for .NET 3.51
Sp1 Version 2 (Astoria)|Add to Project with new SL Client|WebApplication13.
(Note depending on which version of Visual Studio and what versions of WCF Data Services
you have installed on your machine, the choices may vary.)
You will have to click OK to the standard “Add Silverlight Project” screen that Visual
Studio gives you, but the wizard does all the work for you. When you run the application,
the results are an OData service and a simple Silverlight CRUD application:
Stephen 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).
Copyright © 2017, Progress Software Corporation and/or its subsidiaries or affiliates. All Rights Reserved.
Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.