pub struct DbContextOptionsBuilder { /* private fields */ }Implementations§
Source§impl DbContextOptionsBuilder
impl DbContextOptionsBuilder
pub fn new() -> Self
pub fn connection_string(&mut self, cs: impl Into<String>) -> &mut Self
pub fn set_provider(&mut self, tag: &str, cs: impl Into<String>) -> &mut Self
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
Sourcepub fn add_interceptor(
&mut self,
interceptor: impl ISaveChangesInterceptor + 'static,
) -> &mut Self
pub fn add_interceptor( &mut self, interceptor: impl ISaveChangesInterceptor + 'static, ) -> &mut Self
Sourcepub fn use_lazy_loading(&mut self, enabled: bool) -> &mut Self
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);Sourcepub fn context_key(&mut self, key: impl Into<String>) -> &mut Self
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.
Sourcepub fn use_default_entity_model(&mut self) -> &mut Self
pub fn use_default_entity_model(&mut self) -> &mut Self
Shares the default entity model with a keyed context.
add_dbcontext_keyed("key", ...) normally filters entities to those
tagged #[context("key")]. Read and write replicas use the same schema,
so both should call this to discover the default model instead.
.add_dbcontext_keyed("read", |options| {
options.use_default_entity_model();
options.use_mysql(replica_cs);
})