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

How to: Modify Existing Properties

The purpose of this topic is to show you how to modify existing properties in real CLR types. The trick here is to create a new instance of the generic MappingConfiguration<T> class. Next, you should use the HasProperty method to get the configuration object for the desired property. For example, in the code-snippet below is assumed that the Id property of the Category object is not a primary key. By using the mentioned steps you will ensure that the Id property of the Category object is a primary key.

protected override IList<MappingConfiguration> PrepareMapping()
   IList<MappingConfiguration> preparedConfigurations = new List<MappingConfiguration>();

   MappingConfiguration<Category> categoryConfiguration = new MappingConfiguration<Category>();
   categoryConfiguration.HasProperty(c => c.Id).IsIdentity();

   return preparedConfigurations;
Protected Overrides Function PrepareMapping() As IList(Of MappingConfiguration)
 Dim preparedConfigurations As IList(Of MappingConfiguration) = _
     New List(Of MappingConfiguration)()

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

 Return preparedConfigurations
End Function