Skip to main content

DbContextOptionsBuilder

Struct DbContextOptionsBuilder 

Source
pub struct DbContextOptionsBuilder { /* private fields */ }

Implementations§

Source§

impl DbContextOptionsBuilder

Source

pub fn new() -> Self

Source

pub fn connection_string(&mut self, cs: impl Into<String>) -> &mut Self

Source

pub fn set_provider(&mut self, tag: &str, cs: impl Into<String>) -> &mut Self

Source

pub fn set_provider_factory( &mut self, tag: &str, cs: impl Into<String>, factory: Arc<dyn Fn(&str) -> EFResult<Arc<dyn IDatabaseProvider>> + Send + Sync>, ) -> &mut Self

Source

pub fn add_interceptor( &mut self, interceptor: impl ISaveChangesInterceptor + 'static, ) -> &mut Self

Registers a SaveChanges interceptor.

Interceptors are called in registration order during save_changes(). Use this for auditing, soft-delete, validation, and other cross-cutting concerns.

§Example
options
    .use_sqlite("app.db")
    .add_interceptor(AuditInterceptor::new());
Source

pub fn use_lazy_loading(&mut self, enabled: bool) -> &mut Self

Enables or disables lazy loading of navigation properties.

When enabled (true), to_list() attaches a LazyContext to every navigation container on each materialized entity. The user can then call nav.load().await to trigger a single-entity query on first access; subsequent accesses read from the in-memory cache.

When disabled (false, the default), navigation properties are empty unless explicitly loaded via Include — matching v1.0 eager-only behavior.

§Example
let mut options = DbContextOptionsBuilder::new();
options.use_sqlite_in_memory().use_lazy_loading(true);
Source

pub fn context_key(&mut self, key: impl Into<String>) -> &mut Self

Sets the context key used to filter entities and configurations during DbContext::discover_entities(). Set automatically by add_dbcontext_keyed; None (the default) selects the default context.

Source

pub fn build(self) -> DbContextOptions

Trait Implementations§

Source§

impl Default for DbContextOptionsBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.