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

How to: Map Your Model Using Default Mapping

As it was described in the How to: Create a Fluent Mapping Library, the FluentModelMetadataSource class will hold the entire configuration for your classes. It should inherit from FluentMetadataSource and the PrepareMapping method will be your entry point for working with the Telerik Data Access FluentMapping API. Also, it is important to remember that the FluentModelMetadataSource class and your entities must be located in the same project.

You may note that the MapType method of the MappingConfiguration<T> class has two overloads. The first one, which is used in the last example, accepts a lambda expression that allows you to specify the property to column mapping explicitly. The second overload, specifies that all of the property mappings will be handled by Telerik Data Access, i.e. default mapping will be used.

The following code-snippets demonstrate how would look like your PrepareMapping method if you use the default mapping functionality. You can paste the next code in the FluentModelMetadataSource file.

using System.Collections.Generic;
using Telerik.OpenAccess.Metadata.Fluent;
namespace Data
   public class FluentModelMetadataSource : FluentMetadataSource
       protected override IList<MappingConfiguration> PrepareMapping()
           List<MappingConfiguration> configurations = new List<MappingConfiguration>();

           MappingConfiguration<Product> productConfiguration = new MappingConfiguration<Product>();
           productConfiguration.MapType().ToTable( "Products" );
           productConfiguration.HasProperty( p => p.Id ).IsIdentity();
           configurations.Add( productConfiguration );

           MappingConfiguration<Category> categoryConfiguration = new MappingConfiguration<Category>();
           categoryConfiguration.MapType().ToTable( "Categories" );
           categoryConfiguration.HasProperty( p => p.Id ).IsIdentity();
           configurations.Add( categoryConfiguration );

           return configurations;
Public Class FluentModelMetadataSource
    Inherits FluentMetadataSource
    Protected Overrides Function PrepareMapping() As IList(Of MappingConfiguration)
        Dim configurations As New List(Of MappingConfiguration)()

        Dim productConfiguration As New MappingConfiguration(Of Product)()
        productConfiguration.HasProperty(Function(p) p.Id).IsIdentity()
        productConfiguration.FieldNamingRules.AddPrefix = "_"

        Dim categoryConfiguration As New MappingConfiguration(Of Category)()
        categoryConfiguration.HasProperty(Function(p) p.Id).IsIdentity()
        categoryConfiguration.FieldNamingRules.AddPrefix = "_"

        Return configurations
    End Function
End Class

Further References