Table of Contents

Class KEFCoreDbContextOptionsBuilder

Namespace
MASES.EntityFrameworkCore.KNet.Infrastructure
Assembly
MASES.EntityFrameworkCore.KNet.dll

Allows Kafka specific configuration to be performed on DbContextOptions.

public class KEFCoreDbContextOptionsBuilder : IKEFCoreDbContextOptionsBuilderInfrastructure
Inheritance
KEFCoreDbContextOptionsBuilder
Implements
Inherited Members

Remarks

Instances of this class are returned from a call to UseKEFCore(DbContextOptionsBuilder, string?, string, Action<KEFCoreDbContextOptionsBuilder>?) and it is not designed to be directly constructed in your application code.

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

Constructors

KEFCoreDbContextOptionsBuilder(DbContextOptionsBuilder)

Allows Kafka specific configuration to be performed on DbContextOptions.

public KEFCoreDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)

Parameters

optionsBuilder DbContextOptionsBuilder

The options builder.

Remarks

Instances of this class are returned from a call to UseKEFCore(DbContextOptionsBuilder, string?, string, Action<KEFCoreDbContextOptionsBuilder>?) and it is not designed to be directly constructed in your application code.

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

Properties

OptionsBuilder

Clones the configuration in this builder.

protected virtual DbContextOptionsBuilder OptionsBuilder { get; }

Property Value

DbContextOptionsBuilder

The cloned configuration.

Methods

WithCompactedReplicator(bool)

[Obsolete("Option will be removed soon")]
public virtual KEFCoreDbContextOptionsBuilder WithCompactedReplicator(bool useCompactedReplicator = false)

Parameters

useCompactedReplicator bool

If true then KNetCompactedReplicator<K, V> will be used instead of Apache Kafka Streams.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithConsumerConfig(ConsumerConfigBuilder)

Set properties of KNetCompactedReplicator<K, V>.

public virtual KEFCoreDbContextOptionsBuilder WithConsumerConfig(ConsumerConfigBuilder consumerConfigBuilder)

Parameters

consumerConfigBuilder ConsumerConfigBuilder

The ConsumerConfigBuilder where options are stored.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithDefaultConsumerInstances(int?)

Defines the default number of consumer instances to be used in conjunction with WithCompactedReplicator(bool)

public virtual KEFCoreDbContextOptionsBuilder WithDefaultConsumerInstances(int? defaultConsumerInstances = null)

Parameters

defaultConsumerInstances int?

The default number of consumer instances to be used in conjunction with WithCompactedReplicator(bool)

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithDefaultNumPartitions(int)

Defines the default number of partitions to use when a new topic is created

public virtual KEFCoreDbContextOptionsBuilder WithDefaultNumPartitions(int defaultNumPartitions = 1)

Parameters

defaultNumPartitions int

The default number of partitions to use when a new topic is created.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithDefaultReplicationFactor(short)

Defines the default replication factor to use when a new topic is created

public virtual KEFCoreDbContextOptionsBuilder WithDefaultReplicationFactor(short defaultReplicationFactor = 1)

Parameters

defaultReplicationFactor short

The default replication factor to use when a new topic is created.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithDefaultSynchronizationTimeout(long)

The default timeout, expressed in milliseconds, KEFCore will wait for backend to be in-sync with Apache Kafka™ cluster. Setting DefaultSynchronizationTimeout to 0 the synchronization will be disabled

public virtual KEFCoreDbContextOptionsBuilder WithDefaultSynchronizationTimeout(long defaultSynchronizationTimeout)

Parameters

defaultSynchronizationTimeout long

The default timeout, expressed in milliseconds, KEFCore will wait for backend to be in-sync with Apache Kafka™ cluster.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithKeySerDesSelectorType(Type)

Define the external serialization Type for key

public virtual KEFCoreDbContextOptionsBuilder WithKeySerDesSelectorType(Type serializationType)

Parameters

serializationType Type

The Type implementing the serialization model.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithManageEvents(bool)

Setting this property to true if the engine shall reject any write operation, its value will be used to verify if topics has the proper rights WRITE and READ

public virtual KEFCoreDbContextOptionsBuilder WithManageEvents(bool manageEvents)

Parameters

manageEvents bool

true if the engine shall reject any write operation

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithProducerConfig(ProducerConfigBuilder)

Set properties of KafkaProducer.

public virtual KEFCoreDbContextOptionsBuilder WithProducerConfig(ProducerConfigBuilder producerConfigBuilder)

Parameters

producerConfigBuilder ProducerConfigBuilder

The ProducerConfigBuilder where options are stored.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithReadOnlyMode(bool)

Setting this property to true the engine will emit events on ChangeTracker

public virtual KEFCoreDbContextOptionsBuilder WithReadOnlyMode(bool readOnlyMode)

Parameters

readOnlyMode bool

true to receive events from the engine on ChangeTracker

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithStoreKeyRange(bool)

Setting the value to true will enable key range look-up

public virtual KEFCoreDbContextOptionsBuilder WithStoreKeyRange(bool useStoreKeyRange)

Parameters

useStoreKeyRange bool

Set to true to enable single key range look-up in engine based Apache Kafka™ streams.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithStorePrefixScan(bool)

Setting the value to true will enable prefix scan in engine

public virtual KEFCoreDbContextOptionsBuilder WithStorePrefixScan(bool useStorePrefixScan)

Parameters

useStorePrefixScan bool

Set to true to enable prefix scan in engine based Apache Kafka™ streams.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithStoreReverse(bool)

Setting the value to true will enable reverse look-up

public virtual KEFCoreDbContextOptionsBuilder WithStoreReverse(bool useStoreReverse)

Parameters

useStoreReverse bool

Set to true to enable reverse look-up in engine based Apache Kafka™ streams.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithStoreReverseKeyRange(bool)

Setting the value to true will enable reverse key range look-up

public virtual KEFCoreDbContextOptionsBuilder WithStoreReverseKeyRange(bool useStoreReverseKeyRange)

Parameters

useStoreReverseKeyRange bool

Set to true to enable reverse key range look-up in engine based Apache Kafka™ streams.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithStoreSingleKeyLookup(bool)

Setting the value to true will enable single key look-up

public virtual KEFCoreDbContextOptionsBuilder WithStoreSingleKeyLookup(bool useStoreSingleKeyLookup)

Parameters

useStoreSingleKeyLookup bool

Set to true to enable single key look-up in engine based Apache Kafka™ streams.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithStreamsConfig(StreamsConfigBuilder)

Set properties of KafkaStreams.

public virtual KEFCoreDbContextOptionsBuilder WithStreamsConfig(StreamsConfigBuilder streamsConfigBuilder)

Parameters

streamsConfigBuilder StreamsConfigBuilder

The StreamsConfigBuilder where options are stored.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithTopicConfig(TopicConfigBuilder)

Set properties of TopicConfig.

public virtual KEFCoreDbContextOptionsBuilder WithTopicConfig(TopicConfigBuilder topicConfig)

Parameters

topicConfig TopicConfigBuilder

The TopicConfigBuilder where options are stored.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithTopicPrefix(string?)

Define the prefix to be added to the topic name deducted from the model

public virtual KEFCoreDbContextOptionsBuilder WithTopicPrefix(string? topicPrefix)

Parameters

topicPrefix string

The prefix to be added to the topic name deducted from the model.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithUseByteBufferDataTransfer(bool)

Setting this property to true the engine prefers to use ByteBuffer data exchange in serializer instances

public virtual KEFCoreDbContextOptionsBuilder WithUseByteBufferDataTransfer(bool useByteBufferDataTransfer = true)

Parameters

useByteBufferDataTransfer bool

If true, ByteBuffer data exchange will be preferred.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithUseDeletePolicyForTopic(bool)

Enables delete cleanup policy when the topic is created the first time

public virtual KEFCoreDbContextOptionsBuilder WithUseDeletePolicyForTopic(bool useDeletePolicyForTopic = false)

Parameters

useDeletePolicyForTopic bool

If true, then will be used delete cleanup policy when the topic is created the first time.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithUseEnumeratorWithPrefetch(bool)

Setting this property to true the engine prefers to use enumerator instances able to do a prefetch on data speeding up execution

public virtual KEFCoreDbContextOptionsBuilder WithUseEnumeratorWithPrefetch(bool useEnumeratorWithPrefetch = true)

Parameters

useEnumeratorWithPrefetch bool

If true, prefetch in enumeration will be used.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

Used only if UseCompactedReplicator is false and UseKNetStreams is true, not available in EFCore 6 See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithUseGlobalTable(bool)

Setting this property to true the engine based on Streams (i.e. UseCompactedReplicator is false) will use GlobalKTable<K, V> (GlobalKTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) instead of KTable<K, V> (KTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true) to manage local storage of information.

public virtual KEFCoreDbContextOptionsBuilder WithUseGlobalTable(bool useGlobalTable = false)

Parameters

useGlobalTable bool

If true then GlobalKTable<K, V> (GlobalKTable<K, V, TJVMK, TJVMV> if UseKNetStreams is true.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithUseKNetStreams(bool)

Enables use of KNet version of Apache Kafka Streams

public virtual KEFCoreDbContextOptionsBuilder WithUseKNetStreams(bool useKNetStreams = false)

Parameters

useKNetStreams bool

If true then KNet version of Apache Kafka Streams will be used instead of standard Apache Kafka Streams.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithUsePersistentStorage(bool)

Setting this property to true the engine prefers to use enumerator instances able to do a prefetch on data speeding up execution

public virtual KEFCoreDbContextOptionsBuilder WithUsePersistentStorage(bool usePersistentStorage = false)

Parameters

usePersistentStorage bool

If true the engine prefers to use enumerator instances able to do a prefetch on data speeding up execution

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

Used only if UseCompactedReplicator is false and UseKNetStreams is true, not available in EFCore 6. See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithValueContainerType(Type)

Define the external Type which contains the values

public virtual KEFCoreDbContextOptionsBuilder WithValueContainerType(Type serializationType)

Parameters

serializationType Type

The Type implementing the serialization model.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.

WithValueSerDesSelectorType(Type)

Define the external serialization Type for value

public virtual KEFCoreDbContextOptionsBuilder WithValueSerDesSelectorType(Type serializationType)

Parameters

serializationType Type

The Type implementing the serialization model.

Returns

KEFCoreDbContextOptionsBuilder

The same builder instance so that multiple calls can be chained.

Remarks

See Using DbContextOptions, and The EF Core Kafka database provider for more information and examples.