Share via


InMemoryDbContextOptionsExtensions.UseInMemoryDatabase Method

Definition

Overloads

UseInMemoryDatabase(DbContextOptionsBuilder, Action<InMemoryDbContextOptionsBuilder>)
Obsolete.
Obsolete.

Configures the context to connect to the legacy shared in-memory database. This method is obsolete. Use UseInMemoryDatabase(DbContextOptionsBuilder, String, Action<InMemoryDbContextOptionsBuilder>) instead.

UseInMemoryDatabase(DbContextOptionsBuilder, String, Action<InMemoryDbContextOptionsBuilder>)

Configures the context to connect to a named in-memory database. The in-memory database is shared anywhere the same name is used, but only for a given service provider. To use the same in-memory database across service providers, call UseInMemoryDatabase(DbContextOptionsBuilder, String, InMemoryDatabaseRoot, Action<InMemoryDbContextOptionsBuilder>) passing a shared InMemoryDatabaseRoot on which to root the database.

UseInMemoryDatabase(DbContextOptionsBuilder, String, InMemoryDatabaseRoot, Action<InMemoryDbContextOptionsBuilder>)

Configures the context to connect to a named in-memory database. The in-memory database is shared anywhere the same name is used, but only for a given service provider.

UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, Action<InMemoryDbContextOptionsBuilder>)
Obsolete.
Obsolete.

Configures the context to connect to the legacy shared in-memory database. This method is obsolete. Use UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, String, Action<InMemoryDbContextOptionsBuilder>) instead.

UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, String, Action<InMemoryDbContextOptionsBuilder>)

Configures the context to connect to an in-memory database. The in-memory database is shared anywhere the same name is used, but only for a given service provider. To use the same in-memory database across service providers, call UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, String, InMemoryDatabaseRoot, Action<InMemoryDbContextOptionsBuilder>) passing a shared InMemoryDatabaseRoot on which to root the database.

UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, String, InMemoryDatabaseRoot, Action<InMemoryDbContextOptionsBuilder>)

Configures the context to connect to an in-memory database. The in-memory database is shared anywhere the same name is used, but only for a given service provider.

UseInMemoryDatabase(DbContextOptionsBuilder, Action<InMemoryDbContextOptionsBuilder>)

Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs

Caution

Use UseInMemoryDatabase(string) instead. The database will be shared anywhere the same name is used.

Caution

Use UseInMemoryDatabase(string, InMemoryDatabaseRoot) instead.

Configures the context to connect to the legacy shared in-memory database. This method is obsolete. Use UseInMemoryDatabase(DbContextOptionsBuilder, String, Action<InMemoryDbContextOptionsBuilder>) instead.

public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseInMemoryDatabase (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default);
[System.Obsolete("Use UseInMemoryDatabase(string) instead. The database will be shared anywhere the same name is used.")]
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseInMemoryDatabase (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default);
[System.Obsolete("Use UseInMemoryDatabase(string, InMemoryDatabaseRoot) instead.")]
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseInMemoryDatabase (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default);
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
[<System.Obsolete("Use UseInMemoryDatabase(string) instead. The database will be shared anywhere the same name is used.")>]
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
[<System.Obsolete("Use UseInMemoryDatabase(string, InMemoryDatabaseRoot) instead.")>]
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
<Extension()>
Public Function UseInMemoryDatabase (optionsBuilder As DbContextOptionsBuilder, Optional inMemoryOptionsAction As Action(Of InMemoryDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder

Parameters

optionsBuilder
DbContextOptionsBuilder

The builder being used to configure the context.

inMemoryOptionsAction
Action<InMemoryDbContextOptionsBuilder>

An optional action to allow additional in-memory specific configuration.

Returns

The options builder so that further configuration can be chained.

Attributes

Applies to

UseInMemoryDatabase(DbContextOptionsBuilder, String, Action<InMemoryDbContextOptionsBuilder>)

Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs

Configures the context to connect to a named in-memory database. The in-memory database is shared anywhere the same name is used, but only for a given service provider. To use the same in-memory database across service providers, call UseInMemoryDatabase(DbContextOptionsBuilder, String, InMemoryDatabaseRoot, Action<InMemoryDbContextOptionsBuilder>) passing a shared InMemoryDatabaseRoot on which to root the database.

public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseInMemoryDatabase (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default);
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseInMemoryDatabase (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder>? inMemoryOptionsAction = default);
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder * string * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
<Extension()>
Public Function UseInMemoryDatabase (optionsBuilder As DbContextOptionsBuilder, databaseName As String, Optional inMemoryOptionsAction As Action(Of InMemoryDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder

Parameters

optionsBuilder
DbContextOptionsBuilder

The builder being used to configure the context.

databaseName
String

The name of the in-memory database. This allows the scope of the in-memory database to be controlled independently of the context. The in-memory database is shared anywhere the same name is used.

inMemoryOptionsAction
Action<InMemoryDbContextOptionsBuilder>

An optional action to allow additional in-memory specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

See Using DbContextOptions, and The EF Core in-memory database provider for more information and examples.

Applies to

UseInMemoryDatabase(DbContextOptionsBuilder, String, InMemoryDatabaseRoot, Action<InMemoryDbContextOptionsBuilder>)

Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs

Configures the context to connect to a named in-memory database. The in-memory database is shared anywhere the same name is used, but only for a given service provider.

public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseInMemoryDatabase (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string databaseName, Microsoft.EntityFrameworkCore.Storage.InMemoryDatabaseRoot databaseRoot, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default);
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder UseInMemoryDatabase (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder optionsBuilder, string databaseName, Microsoft.EntityFrameworkCore.Storage.InMemoryDatabaseRoot? databaseRoot, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder>? inMemoryOptionsAction = default);
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder * string * Microsoft.EntityFrameworkCore.Storage.InMemoryDatabaseRoot * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder
<Extension()>
Public Function UseInMemoryDatabase (optionsBuilder As DbContextOptionsBuilder, databaseName As String, databaseRoot As InMemoryDatabaseRoot, Optional inMemoryOptionsAction As Action(Of InMemoryDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder

Parameters

optionsBuilder
DbContextOptionsBuilder

The builder being used to configure the context.

databaseName
String

The name of the in-memory database. This allows the scope of the in-memory database to be controlled independently of the context. The in-memory database is shared anywhere the same name is used.

databaseRoot
InMemoryDatabaseRoot

All in-memory databases will be rooted in this object, allowing the application to control their lifetime. This is useful when sometimes the context instance is created explicitly with new while at other times it is resolved using dependency injection.

inMemoryOptionsAction
Action<InMemoryDbContextOptionsBuilder>

An optional action to allow additional in-memory specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

See Using DbContextOptions, and The EF Core in-memory database provider for more information and examples.

Applies to

UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, Action<InMemoryDbContextOptionsBuilder>)

Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs

Caution

Use UseInMemoryDatabase(string) instead. The database will be shared anywhere the same name is used.

Caution

Use UseInMemoryDatabase(string, InMemoryDatabaseRoot) instead.

Configures the context to connect to the legacy shared in-memory database. This method is obsolete. Use UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, String, Action<InMemoryDbContextOptionsBuilder>) instead.

public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInMemoryDatabase<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
[System.Obsolete("Use UseInMemoryDatabase(string) instead. The database will be shared anywhere the same name is used.")]
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInMemoryDatabase<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
[System.Obsolete("Use UseInMemoryDatabase(string, InMemoryDatabaseRoot) instead.")]
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInMemoryDatabase<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
[<System.Obsolete("Use UseInMemoryDatabase(string) instead. The database will be shared anywhere the same name is used.")>]
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
[<System.Obsolete("Use UseInMemoryDatabase(string, InMemoryDatabaseRoot) instead.")>]
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Function UseInMemoryDatabase(Of TContext As DbContext) (optionsBuilder As DbContextOptionsBuilder(Of TContext), Optional inMemoryOptionsAction As Action(Of InMemoryDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder(Of TContext)

Type Parameters

TContext

The type of context being configured.

Parameters

optionsBuilder
DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

inMemoryOptionsAction
Action<InMemoryDbContextOptionsBuilder>

An optional action to allow additional in-memory specific configuration.

Returns

The options builder so that further configuration can be chained.

Attributes

Applies to

UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, String, Action<InMemoryDbContextOptionsBuilder>)

Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs

Configures the context to connect to an in-memory database. The in-memory database is shared anywhere the same name is used, but only for a given service provider. To use the same in-memory database across service providers, call UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, String, InMemoryDatabaseRoot, Action<InMemoryDbContextOptionsBuilder>) passing a shared InMemoryDatabaseRoot on which to root the database.

public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInMemoryDatabase<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInMemoryDatabase<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string databaseName, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder>? inMemoryOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> * string * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Function UseInMemoryDatabase(Of TContext As DbContext) (optionsBuilder As DbContextOptionsBuilder(Of TContext), databaseName As String, Optional inMemoryOptionsAction As Action(Of InMemoryDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder(Of TContext)

Type Parameters

TContext

The type of context being configured.

Parameters

optionsBuilder
DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

databaseName
String

The name of the in-memory database. This allows the scope of the in-memory database to be controlled independently of the context. The in-memory database is shared anywhere the same name is used.

inMemoryOptionsAction
Action<InMemoryDbContextOptionsBuilder>

An optional action to allow additional in-memory specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

See Using DbContextOptions, and The EF Core in-memory database provider for more information and examples.

Applies to

UseInMemoryDatabase<TContext>(DbContextOptionsBuilder<TContext>, String, InMemoryDatabaseRoot, Action<InMemoryDbContextOptionsBuilder>)

Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs
Source:
InMemoryDbContextOptionsExtensions.cs

Configures the context to connect to an in-memory database. The in-memory database is shared anywhere the same name is used, but only for a given service provider.

public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInMemoryDatabase<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string databaseName, Microsoft.EntityFrameworkCore.Storage.InMemoryDatabaseRoot databaseRoot, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> inMemoryOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
public static Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> UseInMemoryDatabase<TContext> (this Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> optionsBuilder, string databaseName, Microsoft.EntityFrameworkCore.Storage.InMemoryDatabaseRoot? databaseRoot, Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder>? inMemoryOptionsAction = default) where TContext : Microsoft.EntityFrameworkCore.DbContext;
static member UseInMemoryDatabase : Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> * string * Microsoft.EntityFrameworkCore.Storage.InMemoryDatabaseRoot * Action<Microsoft.EntityFrameworkCore.Infrastructure.InMemoryDbContextOptionsBuilder> -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)> (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)
<Extension()>
Public Function UseInMemoryDatabase(Of TContext As DbContext) (optionsBuilder As DbContextOptionsBuilder(Of TContext), databaseName As String, databaseRoot As InMemoryDatabaseRoot, Optional inMemoryOptionsAction As Action(Of InMemoryDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder(Of TContext)

Type Parameters

TContext

The type of context being configured.

Parameters

optionsBuilder
DbContextOptionsBuilder<TContext>

The builder being used to configure the context.

databaseName
String

The name of the in-memory database. This allows the scope of the in-memory database to be controlled independently of the context. The in-memory database is shared anywhere the same name is used.

databaseRoot
InMemoryDatabaseRoot

All in-memory databases will be rooted in this object, allowing the application to control their lifetime. This is useful when sometimes the context instance is created explicitly with new while at other times it is resolved using dependency injection.

inMemoryOptionsAction
Action<InMemoryDbContextOptionsBuilder>

An optional action to allow additional in-memory specific configuration.

Returns

The options builder so that further configuration can be chained.

Remarks

See Using DbContextOptions, and The EF Core in-memory database provider for more information and examples.

Applies to