How to: Map New Properties to Columns
This article is relevant to entity models that utilize the deprecated Visual Studio integration of Telerik Data Access. The current documentation of the Data Access framework is available here.
This topic demonstrates how to add new properties to already mapped domain classes.
Suppose, you have a database that contains a table named Customers. You have created a new Telerik Data Access Domain Model based on that database.
In order to add a new property to the Customer entity and map that property to a column:
-
Add a new property to the domain class. For example, create a new DateTime property named HireDate in the Customer entity.
-
You need to create a corresponding column in the underlying table. So, open the Edit Table Dialog. Right-click the domain class and select Edit Table....
-
This will bring the table editor. Add a new column. The SQL Type of the new column should be compatible with the CLR type of the corresponding property. For example, the HireDate property is of type DateTime. That's why the SQL Type for the HireDate column should be datetime. You could specify if the column could accept null values.
Click OK to close the editor and save your domain model.
-
The final step is to map the new property to the corresponding column in the underlying table, i.e. to map the HireDate property to the HireDate column in the Customers table. You will do that in the Mapping Details Editor. Select the Customer class and open the Mapping Details Editor. Map the HireDate property to the corresponding HireDate column from the Customers table.
The property is now mapped. The next step is to migrate the database to the latest state of the model. In order to learn how to do that, check out the How to: Update an Existing Database Schema topic.