gpt4 book ai didi

c# - TDD:EF Core In Memory Provider 是否验证引用约束?

转载 作者:太空狗 更新时间:2023-10-30 01:13:12 25 4
gpt4 key购买 nike

我对 EF Core 用于单元测试的内存功能感到非常兴奋。它减轻了我编写专用存储库的负担,只是为了使代码可单元测试。但仅在集合中进行内存测试是不够的。

Does EF Core In Memory Provider validates referential constraints?

最佳答案

Does EF Core In Memory Provider validates referential constraints?

答案是:没有。

InMemory 提供程序不能替代关系数据库。它是为测试目的而创建的。

摘自 documenation :

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.

第一点是提供者未验证任何约束。

关于c# - TDD:EF Core In Memory Provider 是否验证引用约束?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50999975/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com