Edit this page

Getting Started

This tutorial will walk you through the creation of a sample application that contains RadGridView bound to RadEntityFrameworkDataSource.

You can check the latest changes here.

As of version 2013 Q3 SP1 we have added support for EntityFramework 6.0. You will need to reference the Telerik.Windows.Controls.EntityFramework60 assembly, rather than the Telerik.Windows.Controls.EntityFramework one in order for this to work.

Creating the WPF application

  1. Note that RadEntityFrameworkDataSource is built on top of the ADO.NET Entity Framework. Basic Entity Framework experience is required for working with RadEntityFrameworkDataSource.

  2. Start Visual Studio 2010 and create a new WPF Application.

Creating the Model

Now that we have the application, we will add our entity model using the Northwind database.

  1. In the project add a new ADO.NET Entity Data Model.
    Rad Entity Framework Getting Started 1

  2. Choose the data connection (for example the Northwind database).
    Rad Entity Framework Getting Started 2

  3. Generate the entities from the Orders table of the Northwind database.

  4. Click Finish and rebuild the solution.

Adding RadGridView and RadEntityFrameworkDataSource

Now let's go to the client side.

  1. Add References to the following Telerik assemblies:

  • Telerik.Windows.Controls (mandatory for both RadGridView and RadEntityFrameworkDataSource)

  • Telerik.Windows.Data (mandatory for both RadGridView and RadEntityFrameworkDataSource)

  • Telerik.Windows.Controls.EntityFramework (mandatory for RadEntityFrameworkDataSource with EF 5.0 or previous)

  • Telerik.Windows.Controls.EntityFramework60 (mandatory for RadEntityFrameworkDataSource with EF 6.0 or later)

  • Telerik.Windows.Controls.GridView (mandatory for RadGridView)

  • Telerik.Windows.Controls.Input (mandatory for RadGridView)

  1. Now add the RadGridView and RadEntityFrameworkDataSource controls to the user window. You can add them by dragging them from the Toolbox and dropping it over the XAML or do it manually by writing the XAML code that is shown below.

<Window x:Class="EntityFramework_Example.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&#13;        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&#13;        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"&#13;        xmlns:local="clr-namespace:EntityFramework_Example"
        Title="MainWindow" Height="350" Width="525">
        <telerik:RadEntityFrameworkDataSource Name="OrdersEntityFrameworkDataSource" QueryName="Orders">
        <telerik:RadGridView ItemsSource="{Binding DataView, ElementName=OrdersEntityFrameworkDataSource}"/>

Several important things to notice:
  • The import of the telerik schema: xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation

  • The QueryName points to the query of the data source.

  • ObjectContext - points to the context that has been created.

  • DataView - the data that comes from the query is stored in the DataView property, so we bind the RadGridView to it.

  • Click Ctrl + F5 to run the application and see the gridview populated with the data from the Orders table.

RadEntityFrameworkDataSource.DbContext property.

Since Q3 SP1 2012 we have added the RadEntityFrameworkDataSource.DbContext property which should be set instead of the ObjectContext property for versions of Entity Framework newer than version 5.0.

Please note that this property is available for Entity Framework 5.0 and Entity Framework 6.0 projects targeting .NET Framework 4.5 only.

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article