Skip to content

column mapping

Todd Thomson edited this page Aug 17, 2018 · 2 revisions

Column Mapping

To map an entity property or field to a database table column, you use the .Column method:

modelBuilder.Entity<TodoItem>( entity =>
{
    entity.Column( p => p.Id )
        .IsKey();
}

The following column mapping methods are available:

        /// <summary>
        /// Specifies the column name for this property.
        /// </summary>
        /// <param name="columnName">The name of the column in the underlying data store.</param>
        /// <returns>This <see cref="IColumnMappingBuilder"/> instance.</returns>
        IColumnMappingBuilder ToColumn( string columnName );

        /// <summary>
        /// Sets the column to be a key.
        /// </summary>
        /// <returns>This <see cref="IColumnMappingBuilder"/> instance.</returns>
        IColumnMappingBuilder IsKey();

        /// <summary>
        /// Sets the column ...
        /// </summary>
        /// <returns>This <see cref="IColumnMappingBuilder"/> instance.</returns>
        IColumnMappingBuilder IsRequired();

        /// <summary>
        /// 
        /// </summary>
        /// <returns>This <see cref="IColumnMappingBuilder"/> instance.</returns>
        IColumnMappingBuilder IsUnique();

        /// <summary>
        /// 
        /// </summary>
        void Ignore();