Interface ICollectionMigration<TEntity>
Fluent, typed operations against a single entity's collection/container.
public interface ICollectionMigration<TEntity> where TEntity : class
Type Parameters
TEntityThe entity type.
Methods
AddField<TField>(Expression<Func<TEntity, TField>>)
Adds the stored column for an entity member to an existing table. The member already exists on the entity (and therefore in the model); this evolves the live schema to match. Document stores gain fields on write, so the operation is a no-op there.
ICollectionMigration<TEntity> AddField<TField>(Expression<Func<TEntity, TField>> field)
Parameters
fieldExpression<Func<TEntity, TField>>The member selector.
Returns
- ICollectionMigration<TEntity>
Type Parameters
TFieldThe field type.
CompositeIndex(Action<IIndexKeyBuilder<TEntity>>, bool)
Ensures a composite (multi-key) index exists.
ICollectionMigration<TEntity> CompositeIndex(Action<IIndexKeyBuilder<TEntity>> keys, bool unique = false)
Parameters
keysAction<IIndexKeyBuilder<TEntity>>The fluent key builder (e.g.
k => k.Descending(x => x.A).Ascending(x => x.B)).uniqueboolWhether the index enforces uniqueness.
Returns
- ICollectionMigration<TEntity>
ConvertField<TField>(Expression<Func<TEntity, TField>>, MigrationFieldType, MigrationFieldType)
Converts a field's stored type across existing documents (type/schema evolution).
ICollectionMigration<TEntity> ConvertField<TField>(Expression<Func<TEntity, TField>> field, MigrationFieldType from, MigrationFieldType to)
Parameters
fieldExpression<Func<TEntity, TField>>The field selector.
fromMigrationFieldTypeThe current stored type.
toMigrationFieldTypeThe target stored type.
Returns
- ICollectionMigration<TEntity>
Type Parameters
TFieldThe field type.
DropField(string)
Drops a stored column/field by its stored name — the CLR member is usually already gone, so the name is a string here by design. On document stores this unsets the field across documents.
ICollectionMigration<TEntity> DropField(string field)
Parameters
fieldstringThe stored column/field name.
Returns
- ICollectionMigration<TEntity>
EnsureCollection()
Ensures the collection/container exists.
ICollectionMigration<TEntity> EnsureCollection()
Returns
- ICollectionMigration<TEntity>
Index<TField>(Expression<Func<TEntity, TField>>, Action<IIndexOptions<TEntity>>)
Ensures a single-key index exists with rich, provider-interpreted options — a typed partial filter
(o.Filtered(x => x.DeletedAt == null)), a structure (o.Gin(), o.Text()), a TTL
(o.Ttl(...)) — each rejected with guidance by providers that cannot build it.
ICollectionMigration<TEntity> Index<TField>(Expression<Func<TEntity, TField>> field, Action<IIndexOptions<TEntity>> options)
Parameters
fieldExpression<Func<TEntity, TField>>The field selector.
optionsAction<IIndexOptions<TEntity>>The fluent index options.
Returns
- ICollectionMigration<TEntity>
Type Parameters
TFieldThe field type.
Index<TField>(Expression<Func<TEntity, TField>>, bool, bool)
Ensures a single-key index exists.
ICollectionMigration<TEntity> Index<TField>(Expression<Func<TEntity, TField>> field, bool descending = false, bool unique = false)
Parameters
fieldExpression<Func<TEntity, TField>>The field selector (e.g.
x => x.CreatedAt).descendingboolWhether the key is descending.
uniqueboolWhether the index enforces uniqueness.
Returns
- ICollectionMigration<TEntity>
Type Parameters
TFieldThe field type.
RenameField<TField>(Expression<Func<TEntity, TField>>, string)
Renames a field across existing documents.
ICollectionMigration<TEntity> RenameField<TField>(Expression<Func<TEntity, TField>> field, string newName)
Parameters
fieldExpression<Func<TEntity, TField>>The field selector.
newNamestringThe new field name.
Returns
- ICollectionMigration<TEntity>
Type Parameters
TFieldThe field type.
Update(Expression<Func<TEntity, bool>>, Action<IUpdateBuilder<TEntity>>)
Applies assignments to the documents matching a predicate (a data migration).
ICollectionMigration<TEntity> Update(Expression<Func<TEntity, bool>> predicate, Action<IUpdateBuilder<TEntity>> update)
Parameters
predicateExpression<Func<TEntity, bool>>The predicate selecting the documents.
updateAction<IUpdateBuilder<TEntity>>The fluent assignment builder.
Returns
- ICollectionMigration<TEntity>