EF Core In-Memory Database Provider

Posted 晴天彩虹

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了EF Core In-Memory Database Provider相关的知识,希望对你有一定的参考价值。

原文链接

 

This can be useful for testing, although the SQLite provider in in-memory mode may be a more appropriate test replacement for relational databases.

 

Supported Database Engines

  • Built-in in-memory database (designed for testing purposes only)

Supported Platforms

  • .NET Framework (4.5.1 onwards)

  • .NET Core

  • Mono (4.2.0 onwards)

  • Universal Windows Platform

 

 

Testing with InMemory

The InMemory provider is useful when you want to test components using something that approximates connecting to the real database, without the overhead of actual database operations.

InMemory is not a relational database

EF Core database providers do not have to be relational databases. InMemory is designed to be a general purpose database for testing, and is not designed to mimic a relational database.

Some examples of this include:

  • InMemory will allow you to save data that would violate referential integrity constraints in a relational database.

  • If you use DefaultValueSql(string) for a property in your model, this is a relational database API and will have no effect when running against InMemory.

For many test purposes these differences will not matter. However, if you want to test against something that behaves more like a true relational database, then consider using SQLite in-memory mode.

 

以上是关于EF Core In-Memory Database Provider的主要内容,如果未能解决你的问题,请参考以下文章

EF Core 快速上手——EF Core 入门

EF Core的安装EF Core与数据库结合

raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Databas

EF Core 迁移过程遇到EF Core tools version版本不相符的解决方案

从 EF Core 5 迁移到 EF Core 6 时出错

ef core 子对象集合插入顺序