-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Add Fluent API for Configuration and Entity Type Mappings
Summary
Implement a fluent API that enables configuring general settings (e.g., EnumSerializationMode) and defining entity type mappings in a flexible, code-first style.
Example
DbConnectionExtensions.Configure(config =>
{
config.EnumSerializationMode = EnumSerializationMode.Integers;
config.InterceptDbCommand = (command, tempTables) =>
{
//... log command
};
// Table name mapping:
config.Entity<Product>()
.ToTable("Products");
// Column name mapping:
config.Entity<Product>()
.Property(a => a.Name)
.HasColumnName("ProductName");
// Key column mapping:
config.Entity<Product>()
.Property(a => a.Id)
.IsKey();
// Database generated column mapping:
config.Entity<Product>()
.Property(a => a.DiscountedPrice)
.IsDatabaseGenerated();
// Ignored property mapping:
config.Entity<Product>()
.Property(a => a.IsOnSale)
.Ignore();
}
);Requirements
- General Configuration Support:
- Enable setting global options such as:
EnumSerializationModeInterceptDbCommanddelegate
- Enable setting global options such as:
- Entity Type Mapping Support:
Allow configuring entity types and their properties with the following capabilities:- Specify the table name for an entity
- Specify column names for properties
- Mark one or more properties as primary keys
- Mark properties as database-generated (computed or identity)
- Exclude properties from mapping (ignore them)
Expected behavior
- Fluent API configurations take precedence over any data annotation attributes applied to the entity classes or their properties.
- When a fluent mapping exist for an entity type, the data annotations on this entity type are ignored.
- When a fluent mapping exists for an entity property, the data annotations on this property are ignored.
- If no fluent configuration is provided for an entity type or an entity property, the system falls back to existing behavior using data annotation attributes.
- After
DbConnectionExtensions.Configurehas been called, the configuration of DbConnectionPlus must be frozen. Any further attempt to modify the configuration should throw anInvalidOperationException.
Testing
Provide comprehensive unit and integration tests across all supported database systems to verify:
- General configuration options are applied correctly.
- CRUD operations respect fluent API mappings and function as expected.
- Query translations correctly honor fluent API mappings.
- Temporary table creation and usage behave correctly when configured via fluent API.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels