Table of Contents

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

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

entityTypeBuilder EntityTypeBuilder

The EntityTypeBuilder to configure.

manageEvents bool

true 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

builder EntityTypeBuilder

The EntityTypeBuilder to configure.

acks ProducerConfigBuilder.AcksTypes?

Acknowledgment mode. null to inherit.

lingerMs int?

Batch linger delay in milliseconds. null to inherit.

batchSize int?

Maximum batch size in bytes. null to inherit.

compressionType ProducerConfigBuilder.CompressionTypes?

Compression algorithm. null to inherit.

retries int?

Number of retries on transient failure. null to inherit.

maxInFlightRequestsPerConnection int?

Max unacknowledged requests per connection. null to inherit.

deliveryTimeoutMs int?

Total delivery timeout in milliseconds. null to inherit.

requestTimeoutMs int?

Single request timeout in milliseconds. null to inherit.

bufferMemory long?

Total producer buffer memory in bytes. null to inherit.

maxBlockMs long?

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

builder EntityTypeBuilder

The EntityTypeBuilder to configure.

keySerDesSelectorType Type

Open generic key serializer selector type, or null to inherit.

valueSerDesSelectorType Type

Open generic value container serializer selector type, or null to inherit.

valueContainerType Type

Open 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

builder EntityTypeBuilder

The EntityTypeBuilder to configure.

prefixScan bool?

Enables prefix scan optimization. Default is null (inherit).

singleKeyLookup bool?

Enables single key look-up optimization. Default is null (inherit).

keyRange bool?

Enables key range look-up optimization. Default is null (inherit).

reverse bool?

Enables reverse iteration optimization. Default is null (inherit).

reverseKeyRange bool?

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

builder EntityTypeBuilder

The EntityTypeBuilder to configure.

numPartitions int

The 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

builder EntityTypeBuilder

The EntityTypeBuilder to configure.

replicationFactor short

The 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

builder EntityTypeBuilder

The EntityTypeBuilder to configure.

retentionBytes long

Maximum size in bytes before older segments are deleted. Use -1 to leave at cluster default.

retentionMs long

Maximum retention time in milliseconds. Use -1 to 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

builder EntityTypeBuilder

The EntityTypeBuilder to configure.

transactionGroup string

The 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

builder EntityTypeBuilder

The EntityTypeBuilder to configure.

Returns

EntityTypeBuilder

The same EntityTypeBuilder for chaining.