Class KEFCoreEntityTypeBuilderExtensions
- Namespace
- MASES.EntityFrameworkCore.KNet.Extensions
- Assembly
- MASES.EntityFrameworkCore.KNet.dll
Extension methods for EntityTypeBuilder for the Kafka provider.
public static class KEFCoreEntityTypeBuilderExtensions
- Inheritance
-
KEFCoreEntityTypeBuilderExtensions
- Inherited Members
Remarks
See Modeling entity types and relationships, and The EF Core Kafka database provider for more information and examples.
Methods
HasKEFCoreManageEvents(EntityTypeBuilder, bool)
Sets the KEFCore event management behavior for this entity type, overriding the context-level default.
public static EntityTypeBuilder HasKEFCoreManageEvents(this EntityTypeBuilder entityTypeBuilder, bool manageEvents = true)
Parameters
entityTypeBuilderEntityTypeBuilderThe EntityTypeBuilder to configure.
manageEventsbooltrue to enable event management (default); false to disable it for this entity.
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.
Remarks
Passing false is equivalent to applying KEFCoreIgnoreEventsAttribute on the entity class.
HasKEFCoreProducer(EntityTypeBuilder, AcksTypes?, int?, int?, CompressionTypes?, int?, int?, int?, int?, long?, long?)
Overrides producer configuration for the Kafka topic associated with this entity type. Equivalent to applying KEFCoreProducerAttribute on the entity class. Only explicitly provided parameters override the global ProducerConfig.
public static EntityTypeBuilder HasKEFCoreProducer(this EntityTypeBuilder builder, ProducerConfigBuilder.AcksTypes? acks = null, int? lingerMs = null, int? batchSize = null, ProducerConfigBuilder.CompressionTypes? compressionType = null, int? retries = null, int? maxInFlightRequestsPerConnection = null, int? deliveryTimeoutMs = null, int? requestTimeoutMs = null, long? bufferMemory = null, long? maxBlockMs = null)
Parameters
builderEntityTypeBuilderThe EntityTypeBuilder to configure.
acksProducerConfigBuilder.AcksTypes?Acknowledgment mode. null to inherit.
lingerMsint?Batch linger delay in milliseconds. null to inherit.
batchSizeint?Maximum batch size in bytes. null to inherit.
compressionTypeProducerConfigBuilder.CompressionTypes?Compression algorithm. null to inherit.
retriesint?Number of retries on transient failure. null to inherit.
maxInFlightRequestsPerConnectionint?Max unacknowledged requests per connection. null to inherit.
deliveryTimeoutMsint?Total delivery timeout in milliseconds. null to inherit.
requestTimeoutMsint?Single request timeout in milliseconds. null to inherit.
bufferMemorylong?Total producer buffer memory in bytes. null to inherit.
maxBlockMslong?Max block time when buffer is full in milliseconds. null to inherit.
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.
HasKEFCoreSerDes(EntityTypeBuilder, Type?, Type?, Type?)
Overrides the serialization types for the Kafka topic associated with this entity type.
Equivalent to applying KEFCoreSerDesAttribute on the entity class.
Only the types explicitly provided are stored — omitted parameters inherit the context-level default.
All types must be open generic type definitions (e.g. typeof(MySerDes<>)).
public static EntityTypeBuilder HasKEFCoreSerDes(this EntityTypeBuilder builder, Type? keySerDesSelectorType = null, Type? valueSerDesSelectorType = null, Type? valueContainerType = null)
Parameters
builderEntityTypeBuilderThe EntityTypeBuilder to configure.
keySerDesSelectorTypeTypeOpen generic key serializer selector type, or null to inherit.
valueSerDesSelectorTypeTypeOpen generic value container serializer selector type, or null to inherit.
valueContainerTypeTypeOpen generic value container type, or null to inherit.
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.
HasKEFCoreStoreLookup(EntityTypeBuilder, bool?, bool?, bool?, bool?, bool?)
Configures the Kafka Streams store query optimization flags for this entity type, overriding the context-level defaults from KEFCoreDbContext. Equivalent to applying KEFCoreStoreLookupAttribute on the entity class. Only the flags explicitly provided are stored — omitted parameters retain the context-level default.
public static EntityTypeBuilder HasKEFCoreStoreLookup(this EntityTypeBuilder builder, bool? prefixScan = null, bool? singleKeyLookup = null, bool? keyRange = null, bool? reverse = null, bool? reverseKeyRange = null)
Parameters
builderEntityTypeBuilderThe EntityTypeBuilder to configure.
prefixScanbool?Enables prefix scan optimization. Default is null (inherit).
singleKeyLookupbool?Enables single key look-up optimization. Default is null (inherit).
keyRangebool?Enables key range look-up optimization. Default is null (inherit).
reversebool?Enables reverse iteration optimization. Default is null (inherit).
reverseKeyRangebool?Enables reverse key range look-up optimization. Default is null (inherit).
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.
HasKEFCoreTopicPartitions(EntityTypeBuilder, int)
Sets the number of partitions for the Kafka topic associated with this entity type, overriding DefaultNumPartitions. Equivalent to applying KEFCoreTopicPartitionsAttribute on the entity class. Applied at topic creation time.
public static EntityTypeBuilder HasKEFCoreTopicPartitions(this EntityTypeBuilder builder, int numPartitions)
Parameters
builderEntityTypeBuilderThe EntityTypeBuilder to configure.
numPartitionsintThe number of partitions. Must be greater than zero.
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.
HasKEFCoreTopicReplicationFactor(EntityTypeBuilder, short)
Sets the replication factor for the Kafka topic associated with this entity type, overriding DefaultReplicationFactor. Equivalent to applying KEFCoreTopicReplicationFactorAttribute on the entity class. Applied at topic creation time.
public static EntityTypeBuilder HasKEFCoreTopicReplicationFactor(this EntityTypeBuilder builder, short replicationFactor)
Parameters
builderEntityTypeBuilderThe EntityTypeBuilder to configure.
replicationFactorshortThe replication factor. Must be greater than zero.
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.
HasKEFCoreTopicRetention(EntityTypeBuilder, long, long)
Sets the retention policy for the Kafka topic associated with this entity type, overriding the values in TopicConfig. Equivalent to applying KEFCoreTopicRetentionAttribute on the entity class. Applied at topic creation time.
public static EntityTypeBuilder HasKEFCoreTopicRetention(this EntityTypeBuilder builder, long retentionBytes = -1, long retentionMs = -1)
Parameters
builderEntityTypeBuilderThe EntityTypeBuilder to configure.
retentionByteslongMaximum size in bytes before older segments are deleted. Use
-1to leave at cluster default.retentionMslongMaximum retention time in milliseconds. Use
-1to leave at cluster default.
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.
HasKEFCoreTransactionGroup(EntityTypeBuilder, string)
Assigns this entity type to a Kafka transaction group, enabling exactly-once semantics
for all entity types sharing the same transactionGroup.
Equivalent to applying KEFCoreTransactionalAttribute on the entity class.
public static EntityTypeBuilder HasKEFCoreTransactionGroup(this EntityTypeBuilder builder, string transactionGroup)
Parameters
builderEntityTypeBuilderThe EntityTypeBuilder to configure.
transactionGroupstringThe transaction group name. All entity types sharing this name will participate in the same Kafka transaction. Must be non-empty.
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.
IsKEFCoreReadOnly(EntityTypeBuilder)
Marks this entity type as read-only, preventing any write via SaveChanges(). Equivalent to applying KEFCoreReadOnlyAttribute on the entity class. Unlike ReadOnlyMode which applies to the entire context, this applies only to this entity type.
public static EntityTypeBuilder IsKEFCoreReadOnly(this EntityTypeBuilder builder)
Parameters
builderEntityTypeBuilderThe EntityTypeBuilder to configure.
Returns
- EntityTypeBuilder
The same EntityTypeBuilder for chaining.