Class EfCoreDataSourceOptions
- Namespace
- Savvyio.Extensions.EFCore
- Assembly
- Savvyio.Extensions.EFCore.dll
Configuration options for IEfCoreDataSource.
public class EfCoreDataSourceOptions : IParameterObject
- Inheritance
-
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
EfCoreDataSourceOptions()
Initializes a new instance of the EfCoreDataSourceOptions class.
public EfCoreDataSourceOptions()
Properties
ContextConfigurator
Gets or sets the delegate responsible for configuring the DbContext.
public Action<DbContextOptionsBuilder> ContextConfigurator { get; set; }
Property Value
- Action<DbContextOptionsBuilder>
The delegate responsible for configuring the DbContext.
ConventionsConfigurator
Gets or sets the delegate responsible for configuring defaults and conventions of the DbContext.
public Action<ModelConfigurationBuilder> ConventionsConfigurator { get; set; }
Property Value
- Action<ModelConfigurationBuilder>
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.
public Action<ModelBuilder> ModelConstructor { get; set; }
Property Value
- Action<ModelBuilder>
The delegate responsible for configuring the model of the DbContext.