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

How to: Refer Telerik® Data Access Library from Other Projects

This tutorial will demonstrate to you how to refer a class library that contains a Data Access model from other projects. There are two general scenarios:

  • Referring a Data Access class library from another class library project.
  • Referring a Data Access class library from the main (executable) project.

This tutorial requires you to create the SofiaCarRental model on your side.

Referring a Telerik Data Access Class Library from Another Class Library Project

The SofiaCarRental.Model assembly contains your fluent model. Suppose, you want to refer the assembly in another class library projects (e.g. Windows Forms Control Library, WPF Custom Control Library, WPF User Control Library, etc.).

To refer the Data Access class library from another class library project, you need to perform the following actions:

  • In the second class library project, add a reference to the Data Access model assembly(e.g., SofiaCarRental.Model).
  • Integrate the second class library project with the Telerik.DataAccess.Core NuGet package. Also you might need to add other Telerik Data Access packages, depending on the functionality you are using.

Referring a Telerik Data Access Class Library from Client Projects (WebSite, Web Application, Exe, etc.)

In order to use the model in client projects, you need to perform three steps:

  • In the main project, add a reference to the Data Access model assembly(e.g., SofiaCarRental.Model).
  • Integrate the main project with the Telerik.DataAccess.Core NuGet package. Also you might need to add other Telerik Data Access packages, depending on the functionality you are using.

    For ASP.NET MVC projects, you need to set Copy Local for Telerik.OpenAccess.dll to True - In Solution Explorer, expand the References node for the client project. Select the Telerik.OpenAccess.dll assembly, press F4 to open the Properties pane and set the Copy Local property to True.

  • The last step is to ensure that the client project "has" the ability to know about the model, i.e. to have an access to the database connection string used by the rlinq file. What you normally do when you have an existing config file in the client project is to copy the connection string from the App.config in the library project and paste it in the <connectionStrings/> section in the client config file.

    If you don't have an existing config file in the client project, as in this example, you simply could copy and paste the entire config file.

For more information about this scenario, you could refer to Consuming a Model - Configuration.

For further reference, check out the Managing the OpenAccessContext section: