简体   繁体   English

如何使用 Entity Framework 6 在内存中创建 DbContext?

[英]How do I create an in memory DbContext with Entity Framework 6?

How do I create an in memory version of a DbContext for testing in entity framework 6?如何创建 DbContext 的内存版本以在实体框架 6 中进行测试? I cannot use .NET core for this project, it must be ef 6. I already have a custom db context created that connects to sql server and works great.我不能在这个项目中使用 .NET 核心,它必须是 ef 6。我已经创建了一个自定义 db 上下文,它连接到 sql server 并且运行良好。

Doing this in .NET core is trivial, I am hoping something exists for legacy entity framework / .NET framework as well, but so far no luck on my searches...在 .NET 核心中执行此操作是微不足道的,我希望遗留实体框架/.NET 框架也存在一些东西,但到目前为止我的搜索没有运气......

您可以尝试使用此 EF6 内存中提供程序: https : //entityframework-effort.net/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Entity Framework Core 中将连接字符串传递给 DBContext? - How do I pass connection string to DBContext in Entity Framework Core? 如何创建实体框架 DBContext 扩展方法? - How to Create Entity Framework DBContext Extension Method? 实体框架DbContext如何将记录加载到内存中 - Entity Framework DbContext How to Eager Load Records Into Memory 如何基于具有实体框架的现有 DbContext 为 Docker 图像创建 SQL 服务器数据库方案? - How can I create the SQL Server database scheme for a Docker image based on an existing DbContext with Entity Framework? 在使用1个DBContext执行Entity Framework操作时,如何在WPF中显示加载窗口? - how do I show a loading window in WPF while performing Entity Framework operations with 1 DBContext? 如何修改自动生成的实体框架DbContext属性? - How do I modify an auto-generated Entity Framework DbContext Property? 如何在实体框架核心中创建DBContext作为现有事务的一部分 - How to create a DBContext as part of an existing transaction in Entity Framework Core 如何在DbContext之外使用Entity Framework之前创建数据库? - How to make Entity Framework create database before using it outside DbContext? 如何使用实体框架dbcontext对单个属性的每个字符串执行“ StartsWith”搜索 - How can I do a 'StartsWith' search on each string of a single attribute using entity framework dbcontext 如何正确地对与Entity Framework / DbContext耦合的存储库模式方法进行单元测试? - How do I properly unit test a repository-pattern method, that has coupling to Entity Framework / DbContext?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM