Skip to content

Commit 43fa600

Browse files
committed
Update guidance around in-memory database
Fixes #2602
1 parent b2a9d7f commit 43fa600

File tree

5 files changed

+25
-22
lines changed

5 files changed

+25
-22
lines changed

entity-framework/core/dbcontext-configuration/index.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -234,15 +234,15 @@ These `Use*` methods are extension methods implemented by the database provider.
234234
235235
The following table contains examples for common database providers.
236236

237-
| Database system | Example configuration | NuGet package
238-
|:-----------------------------|-----------------------------------------------|--------------
239-
| SQL Server or Azure SQL | `.UseSqlServer(connectionString)` | [Microsoft.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/)
240-
| Azure Cosmos DB | `.UseCosmos(connectionString, databaseName)` | [Microsoft.EntityFrameworkCore.Cosmos](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Cosmos/)
241-
| SQLite | `.UseSqlite(connectionString)` | [Microsoft.EntityFrameworkCore.Sqlite](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Sqlite/)
242-
| EF Core in-memory database | `.UseInMemoryDatabase(databaseName)` | [Microsoft.EntityFrameworkCore.InMemory](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.InMemory/)
243-
| PostgreSQL* | `.UseNpgsql(connectionString)` | [Npgsql.EntityFrameworkCore.PostgreSQL](https://www.nuget.org/packages/Npgsql.EntityFrameworkCore.PostgreSQL/)
244-
| MySQL/MariaDB* | `.UseMySql(connectionString)` | [Pomelo.EntityFrameworkCore.MySql](https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql/)
245-
| Oracle* | `.UseOracle(connectionString)` | [Oracle.EntityFrameworkCore](https://www.nuget.org/packages/Oracle.EntityFrameworkCore/)
237+
| Database system | Example configuration | NuGet package |
238+
|:---------------------------|----------------------------------------------|--------------------------------------------------------------------------------------------------------------------|
239+
| SQL Server or Azure SQL | `.UseSqlServer(connectionString)` | [Microsoft.EntityFrameworkCore.SqlServer](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.SqlServer/) |
240+
| Azure Cosmos DB | `.UseCosmos(connectionString, databaseName)` | [Microsoft.EntityFrameworkCore.Cosmos](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Cosmos/) |
241+
| SQLite | `.UseSqlite(connectionString)` | [Microsoft.EntityFrameworkCore.Sqlite](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.Sqlite/) |
242+
| EF Core in-memory database | `.UseInMemoryDatabase(databaseName)` | [Microsoft.EntityFrameworkCore.InMemory](https://www.nuget.org/packages/Microsoft.EntityFrameworkCore.InMemory/) |
243+
| PostgreSQL* | `.UseNpgsql(connectionString)` | [Npgsql.EntityFrameworkCore.PostgreSQL](https://www.nuget.org/packages/Npgsql.EntityFrameworkCore.PostgreSQL/) |
244+
| MySQL/MariaDB* | `.UseMySql(connectionString)` | [Pomelo.EntityFrameworkCore.MySql](https://www.nuget.org/packages/Pomelo.EntityFrameworkCore.MySql/) |
245+
| Oracle* | `.UseOracle(connectionString)` | [Oracle.EntityFrameworkCore](https://www.nuget.org/packages/Oracle.EntityFrameworkCore/) |
246246

247247
*These database providers are not shipped by Microsoft. See [Database Providers](xref:core/providers/index) for more information about database providers.
248248

entity-framework/core/providers/in-memory/index.md

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
---
2-
title: InMemory Database Provider - EF Core
3-
description: Information on the Entity Framework Core InMemory database provider
2+
title: In-memory Database Provider - EF Core
3+
description: Information on the Entity Framework Core in-memory database provider
44
author: ajcvickers
5-
ms.date: 10/27/2016
5+
ms.date: 02/11/2023
66
uid: core/providers/in-memory/index
77
---
88
# EF Core In-Memory Database Provider
99

10-
This database provider allows Entity Framework Core to be used with an in-memory database. While some users use the in-memory database for testing, this is generally discouraged; the SQLite provider in in-memory mode is a more appropriate test replacement for relational databases. For more information on how to test EF Core applications, see the [testing documentation](xref:core/testing/index). The provider is maintained as part of the [Entity Framework Core Project](https://github.com/dotnet/efcore).
10+
This database provider allows Entity Framework Core to be used with an in-memory database. While some users use the in-memory database for testing, this is discouraged. For more information on how to test EF Core applications, see the [_Testing EF Core Applications_](xref:core/testing/index). The provider is maintained by Microsoft as part of the [Entity Framework Core Project](https://github.com/dotnet/efcore).
1111

1212
> [!WARNING]
13-
> The In-Memory provider was not designed for use outside of testing environments and should never be used as such.
13+
> The EF Core in-memory database is not designed for performance or robustness and should not be used outside of testing environments. It is not designed for production use.
14+
15+
> [!IMPORTANT]
16+
> New features are not being added to the in-memory database.
1417
1518
## Install
1619

@@ -34,9 +37,9 @@ Install-Package Microsoft.EntityFrameworkCore.InMemory
3437

3538
The following resources will help you get started with this provider.
3639

37-
* [Testing with InMemory](xref:core/testing/testing-without-the-database#inmemory-provider)
40+
* [Testing with in-memory (not recommended)](xref:core/testing/testing-without-the-database#inmemory-provider)
3841
* [UnicornStore Sample Application Tests](https://github.com/rowanmiller/UnicornStore/blob/master/UnicornStore/src/UnicornStore.Tests/Controllers/ShippingControllerTests.cs)
3942

4043
## Supported Database Engines
4144

42-
In-process memory database, designed for testing purposes only.
45+
In-process naive, non-performant, and non-persisted in-memory database. Not designed for production use.

entity-framework/core/what-is-new/ef-core-5.0/breaking-changes.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ The following API and behavior changes have the potential to break existing appl
3030
| [Value generators are called when the entity state is changed from Detached to Unchanged, Updated, or Deleted](#non-added-generation) | Low |
3131
| [IMigrationsModelDiffer now uses IRelationalModel](#relational-model) | Low |
3232
| [Discriminators are read-only](#read-only-discriminators) | Low |
33-
| [Provider-specific EF.Functions methods throw for InMemory provider](#no-client-methods) | Low |
33+
| [Provider-specific EF.Functions methods throw for in-memory provider](#no-client-methods) | Low |
3434
| [IndexBuilder.HasName is now obsolete](#index-obsolete) | Low |
3535
| [A pluralizer is now included for scaffolding reverse engineered models](#pluralizer) | Low |
3636
| [INavigationBase replaces INavigation in some APIs to support skip navigations](#inavigationbase) | Low |
@@ -525,21 +525,21 @@ modelBuilder.Entity<BaseEntity>()
525525

526526
<a name="no-client-methods"></a>
527527

528-
### Provider-specific EF.Functions methods throw for InMemory provider
528+
### Provider-specific EF.Functions methods throw for in-memory provider
529529

530530
[Tracking Issue #20294](https://github.com/dotnet/efcore/issues/20294)
531531
532532
#### Old behavior
533533

534-
Provider-specific EF.Functions methods contained implementation for client execution, which allowed them to be executed on the InMemory provider. For example, `EF.Functions.DateDiffDay` is a Sql Server specific method, which worked on InMemory provider.
534+
Provider-specific EF.Functions methods contained implementation for client execution, which allowed them to be executed on the in-memory provider. For example, `EF.Functions.DateDiffDay` is a Sql Server specific method, which worked on InMemory provider.
535535

536536
#### New behavior
537537

538538
Provider-specific methods have been updated to throw an exception in their method body to block evaluating them on client side.
539539

540540
#### Why
541541

542-
Provider-specific methods map to a database function. The computation done by the mapped database function can't always be replicated on the client side in LINQ. It may cause the result from the server to differ when executing the same method on client. Since these methods are used in LINQ to translate to specific database functions, they don't need to be evaluated on client side. As InMemory provider is a different _database_, these methods aren't available for this provider. Trying to execute them for InMemory provider, or any other provider that doesn't translate these methods, throws an exception.
542+
Provider-specific methods map to a database function. The computation done by the mapped database function can't always be replicated on the client side in LINQ. It may cause the result from the server to differ when executing the same method on client. Since these methods are used in LINQ to translate to specific database functions, they don't need to be evaluated on client side. As the in-memory provider is a different _database_, these methods aren't available for this provider. Trying to execute them for InMemory provider, or any other provider that doesn't translate these methods, throws an exception.
543543

544544
#### Mitigations
545545

entity-framework/core/what-is-new/ef-core-5.0/whatsnew.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,4 +385,4 @@ For further information, [see the full documentation on event counters](xref:cor
385385
* The EF Core command line tools now automatically configure the `ASPNETCORE_ENVIRONMENT` *and* `DOTNET_ENVIRONMENT` environment variables to "Development". This brings the experience when using the generic host in line with the experience for ASP.NET Core during development.
386386
* Custom command-line arguments can be flowed into <xref:Microsoft.EntityFrameworkCore.Design.IDesignTimeDbContextFactory%601>, allowing applications to control how the context is created and initialized.
387387
* The index fill factor can now be [configured on SQL Server](xref:core/providers/sql-server/indexes#fill-factor).
388-
* The new <xref:Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.IsRelational%2A> property can be used to distinguish when using a relational provider and a non-relation provider (such as InMemory).
388+
* The new <xref:Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.IsRelational%2A> property can be used to distinguish when using a relational provider and a non-relation provider (such as in-memory).

entity-framework/toc.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@
401401
href: core/providers/cosmos/functions.md
402402
- name: End-to-end sample
403403
href: core/providers/cosmos/planetary-docs-sample.md
404-
- name: InMemory (for testing)
404+
- name: In-memory (not recommended)
405405
href: core/providers/in-memory/index.md
406406
- name: Write a database provider
407407
href: core/providers/writing-a-provider.md

0 commit comments

Comments
 (0)