How to: Create a New Model
In this topic you will learn how to set up a Telerik Data Access project for use with Oracle database.
Installing the Oracle ODP.NET Driver
Telerik Data Access uses the ADO.NET (Oracle.DataAcces.Client) Provider from Oracle called ODP.NET and the ODP.NET Managed driver. In order to create a new model based on a Oracle database, you have to install either the ODP.NET Driver from Oracle, or ODP.NET Oracle, Managed Driver. You can download it from here.
Creating a New Empty model
For this tutorial, you need to create a new class library project for the model.
- Start Visual Studio, on the File menu select New, and then select Project.
- In the New Project dialog box, select Visual Basic or Visual C# as the programming language.
- In the Templates pane, select Class Library project.
- Type OracleData as the name of the project. Click OK.
- Integrate the project with the Telerik.DataAccess.Fluent NuGet package.
-
In the App.config file of the project, provide the connection string to the database:
With TNSNAMES.ORA
<connectionStrings> <add name="OracleConnection" connectionString="data source=MYTNSORA;password=MyPassword; persist security info=True;user id=MyUser" providerName="Oracle.ManagedDataAccess.Client" /> </connectionStrings>
Without TNSNAMES.ORA
<connectionStrings> <add name="OracleConnection" connectionString="SERVER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP) (HOST=MyHost)(PORT=MyPort)) (CONNECT_DATA=(SERVICE_NAME=MyOracleSID))); uid=myUsername;pwd=myPassword; persist security info=True" providerName="Oracle.ManagedDataAccess.Client" /> </connectionStrings>
Create POCO classes for your persistent entities.
- Using the Fluent Mapping API create the metadatasource class where the mapping is defined. An example is available here.
- Create your context class.
At this point you cat test the model through any application that is integrated with the Telerik.DataAccess.Core NuGet package.