Table of Contents

Class KafkaDbContextOptionsBuilder

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

Allows Kafka specific configuration to be performed on DbContextOptions.

public class KafkaDbContextOptionsBuilder : IKafkaDbContextOptionsBuilderInfrastructure
Inheritance
KafkaDbContextOptionsBuilder
Implements
Inherited Members

Remarks

Instances of this class are returned from a call to UseKafkaCluster(DbContextOptionsBuilder, string, string, string, Action<KafkaDbContextOptionsBuilder>?) 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

KafkaDbContextOptionsBuilder(DbContextOptionsBuilder)

Initializes a new instance of the KafkaDbContextOptionsBuilder class.

public KafkaDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)

Parameters

optionsBuilder DbContextOptionsBuilder

The options builder.

Properties

OptionsBuilder

Clones the configuration in this builder.

protected virtual DbContextOptionsBuilder OptionsBuilder { get; }

Property Value

DbContextOptionsBuilder

The cloned configuration.

Methods

WithCompactedReplicator(bool)

public virtual KafkaDbContextOptionsBuilder WithCompactedReplicator(bool useCompactedReplicator = false)

Parameters

useCompactedReplicator bool

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

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithConsumerConfig(ConsumerConfigBuilder consumerConfigBuilder)

Parameters

consumerConfigBuilder ConsumerConfigBuilder

The ConsumerConfigBuilder where options are stored.

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithDefaultConsumerInstances(int? defaultConsumerInstances = null)

Parameters

defaultConsumerInstances int?

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

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithDefaultNumPartitions(int defaultNumPartitions = 1)

Parameters

defaultNumPartitions int

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

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithDefaultReplicationFactor(short defaultReplicationFactor = 1)

Parameters

defaultReplicationFactor short

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

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithKeySerDesSelectorType(Type serializationType)

Parameters

serializationType Type

The Type implementing the serialization model.

Returns

KafkaDbContextOptionsBuilder

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.

WithOnChangeEvent(Action<EntityTypeChanged>)

Set the optional handler to be used to receive notification when the back-end triggers a data change. Works if WithCompactedReplicator(bool) is invoked with true

public virtual KafkaDbContextOptionsBuilder WithOnChangeEvent(Action<EntityTypeChanged> onChangeEvent)

Parameters

onChangeEvent Action<EntityTypeChanged>

The Action<T1, T2, T3> will be used to report change event.

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithProducerConfig(ProducerConfigBuilder producerConfigBuilder)

Parameters

producerConfigBuilder ProducerConfigBuilder

The ProducerConfigBuilder where options are stored.

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithStreamsConfig(StreamsConfigBuilder streamsConfigBuilder)

Parameters

streamsConfigBuilder StreamsConfigBuilder

The StreamsConfigBuilder where options are stored.

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithTopicConfig(TopicConfigBuilder topicConfig)

Parameters

topicConfig TopicConfigBuilder

The TopicConfigBuilder where options are stored.

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithUseByteBufferDataTransfer(bool useByteBufferDataTransfer = true)

Parameters

useByteBufferDataTransfer bool

If true, ByteBuffer data exchange will be preferred.

Returns

KafkaDbContextOptionsBuilder

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

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithUseEnumeratorWithPrefetch(bool useEnumeratorWithPrefetch = true)

Parameters

useEnumeratorWithPrefetch bool

If true, prefetch in enumeration will be used.

Returns

KafkaDbContextOptionsBuilder

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.

WithUseKNetStreams(bool)

Enables use of KNet version of Apache Kafka Streams

public virtual KafkaDbContextOptionsBuilder 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

KafkaDbContextOptionsBuilder

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.

WithUseNameMatching(bool)

Enables name matching on IEntityType instead of Type matching

public virtual KafkaDbContextOptionsBuilder WithUseNameMatching(bool useNameMatching = true)

Parameters

useNameMatching bool

If true, it is used name matching.

Returns

KafkaDbContextOptionsBuilder

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

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithValueContainerType(Type serializationType)

Parameters

serializationType Type

The Type implementing the serialization model.

Returns

KafkaDbContextOptionsBuilder

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 KafkaDbContextOptionsBuilder WithValueSerDesSelectorType(Type serializationType)

Parameters

serializationType Type

The Type implementing the serialization model.

Returns

KafkaDbContextOptionsBuilder

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.