Table of Contents

EfCoreDataSourceOptions Class

Definition

Namespace
Savvyio.Extensions.EFCore
Assemblies
Savvyio.Extensions.EFCore.dll
Source
src/Savvyio.Extensions.EFCore/EfCoreDataSourceOptions.cs

Configuration options for IEfCoreDataSource.

public class EfCoreDataSourceOptions : IParameterObject
Inheritance
object
EfCoreDataSourceOptions
Implements
Derived

Examples

This example shows how EfCoreDataSourceOptions centralizes model and context configuration for an EF Core-backed source.

using System;
using Microsoft.EntityFrameworkCore;
using Savvyio;
using Savvyio.Extensions.EFCore;

namespace ExampleApp;

public sealed class CatalogConfiguration
{
    public EfCoreDataSource CreateSource()
    {
        var options = new EfCoreDataSourceOptions
        {
            ContextConfigurator = builder => builder.EnableSensitiveDataLogging(),
            ModelConstructor = modelBuilder =>
            {
                modelBuilder.Entity<Product>().HasKey(product => product.Id);
                modelBuilder.Entity<Product>().Property(product => product.Name).HasMaxLength(128);
            }
        };

        return new EfCoreDataSource(options);
    }
}

public sealed class Product : IIdentity<Guid>
{
    public Product(Guid id, string name)
    {
        Id = id;
        Name = name;
    }

    public Guid Id { get; }

    public string Name { get; private set; } = string.Empty;
}

Constructors

Name Description
EfCoreDataSourceOptions()

Initializes a new instance of the EfCoreDataSourceOptions class.

Properties

Name Description
ContextConfigurator

Gets or sets the delegate responsible for configuring the DbContext.

ConventionsConfigurator

Gets or sets the delegate responsible for configuring defaults and conventions of the DbContext.

ModelConstructor

Gets or sets the delegate responsible for configuring the model of the DbContext.