Begin by creating a new WPF project in Visual Studio. Then you will add a connection to the Northwind database.
-
In Visual Studio, choose File | New | Project.
-
Select the WPF Application template and click OK.
-
Next, add an Entity Data Model based on the Northwind database. This model will provide the data for the entire application.
-
In the Solution Explorer, right-click the project name and select Add | New Item.
-
Choose the ADO.NET Entity Data Model item and then click Add.
-
In the Entity Data Model Wizard, select Generate from database to generate the model from the Northwind database, and then click Next.
-
Click the New Connection button.
-
In the Choose Data Source dialog box, select Microsoft SQL Server Database File and click Continue.
-
Browse to find the NORTHWND.MDF, select it, and click Open. The NORTHWND.MDF is installed with the product at the following location:
Documents\ComponentOne Samples\Common
-
Click OK and then click Next.
-
In the Choose Your Database Objects window, select Tables and click Finish. Note that if a Security Warning dialog box appears click OK.
-
In the Solution Explorer, expand the Model1.edmx node.
-
Delete the Model1.Context.tt file.
-
Delete the Model1.tt file.
-
In the Model Browser, right click the Diagram and select Add Code Generation Item from the context menu.
-
In the Add New Item Dialog box, select ‘ComponentOne EF 6.x DbContext Generator’.
|
Note: When you install DataSource for Entity Framework, ComponentOne EF6.x DBContext Code Generation Templates will be added to each version of Visual Studio that C1DataSource supports. These templates ensure that the DBContext models that you create, provide entities that support INotifyPropertyChanged. |
Now build the project so the new Entity Data Model classes are generated and become available throughout the project. Once they are available, you will be able to connect the data to the C1DataSource component.