模拟实体框架上下文 [英] Mocking Entity Framework Context
问题描述
有没有人能做到这一点?
你可以只用元数据来做,有一篇很好的文章,单元测试一般来说, =http://blogs.msdn.com/diego/archive/2008/03/03/unit-testing-your-entity-framework-domain-classes.aspx =noreferrer> here
。I'm using the entity framework to access my database and I want to mock the database context inside my unit tests so that I can test my middle tier classes free of their dependency on real data. I know that I'm not the first to ask about this (Mocking an Entity Framework Model), but after some googling I have an instinct that it might be possible to instantiate the context based on the model's metadata alone.
Has anyone been able to do this?
You can do it with just metadata, there's a good article on it, and unit testing EF in general, here.
这篇关于模拟实体框架上下文的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!