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>.

[Obsolete("Option will be removed soon")]
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)

[Obsolete("Option will be removed soon")]
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.

WithDeletePolicyForTopic(bool)

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

public virtual KEFCoreDbContextOptionsBuilder WithDeletePolicyForTopic(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.

WithEnumeratorWithPrefetch(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 WithEnumeratorWithPrefetch(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.

WithGlobalTable(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 WithGlobalTable(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.

WithKNetStreams(bool)

Enables use of KNet version of Apache Kafka Streams

public virtual KEFCoreDbContextOptionsBuilder WithKNetStreams(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.

WithKeyByteBufferDataTransfer(bool)

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

public virtual KEFCoreDbContextOptionsBuilder WithKeyByteBufferDataTransfer(bool useKeyByteBufferDataTransfer = true)

Parameters

useKeyByteBufferDataTransfer bool

If true, ByteBuffer data exchange will be preferred for key.

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.

WithPersistentStorage(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 WithPersistentStorage(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.

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.

WithSaslConfig(SaslConfigsBuilder)

Set properties of SaslConfigsBuilder.

public virtual KEFCoreDbContextOptionsBuilder WithSaslConfig(SaslConfigsBuilder saslConfigsBuilder)

Parameters

saslConfigsBuilder SaslConfigsBuilder

The SaslConfigsBuilder 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.

WithSecurityProtocol(SecurityProtocol)

Set properties of SecurityProtocol.

public virtual KEFCoreDbContextOptionsBuilder WithSecurityProtocol(SecurityProtocol securityProtocol)

Parameters

securityProtocol SecurityProtocol

The SecurityProtocol 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.

WithSslConfig(SslConfigsBuilder)

Set properties of SslConfigsBuilder.

public virtual KEFCoreDbContextOptionsBuilder WithSslConfig(SslConfigsBuilder sslConfigsBuilder)

Parameters

sslConfigsBuilder SslConfigsBuilder

The SslConfigsBuilder 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.

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.

WithValueContainerByteBufferDataTransfer(bool)

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

public virtual KEFCoreDbContextOptionsBuilder WithValueContainerByteBufferDataTransfer(bool useValueContainerByteBufferDataTransfer = true)

Parameters

useValueContainerByteBufferDataTransfer bool

If true, ByteBuffer data exchange will be preferred for value container.

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.

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.