Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Does using repository pattern add complexity? In your scenario I don't think so. It makes TDD easier and your code more manageable. Try to use a Generic repository pattern for more separation and cleaner code. </p> <p>If you want to find out more about TDD and design patterns in Entity Framework, take a look at: <a href="http://msdn.microsoft.com/en-us/ff714955.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/ff714955.aspx</a> </p> <p>However it seems like you're looking for an approach to mock test Entity Framework. One solution would be using a virtual seed method to generate data on database initialization. Take a look at <strong>Seed</strong> section at: <a href="http://blogs.msdn.com/b/adonet/archive/2010/09/02/ef-feature-ctp4-dbcontext-and-databases.aspx" rel="nofollow noreferrer">http://blogs.msdn.com/b/adonet/archive/2010/09/02/ef-feature-ctp4-dbcontext-and-databases.aspx</a> </p> <p>Also you can use some mocking frameworks. The most famous ones I know are: </p> <ul> <li><a href="http://www.ayende.com/projects/rhino-mocks.aspx" rel="nofollow noreferrer">Rhino Mocks</a></li> <li><a href="http://code.google.com/p/moq/" rel="nofollow noreferrer">Moq</a> </li> <li><a href="http://www.typemock.com/" rel="nofollow noreferrer">Typemock</a> (Commercial)</li> </ul> <p>To see a more complete list of .NET mocking frameworks, check out: <a href="https://stackoverflow.com/questions/37359/what-c-mocking-framework-to-use">https://stackoverflow.com/questions/37359/what-c-mocking-framework-to-use</a> </p> <p>Another approach would be to use an in-memory database provider like <a href="http://sqlite.phxsoftware.com/" rel="nofollow noreferrer">SQLite</a>. Study more at <a href="https://stackoverflow.com/questions/575190/is-there-an-in-memory-provider-for-entity-framework/575413#575413">Is there an in-memory provider for Entity Framework?</a> </p> <p>Finally, here are some good links about unit testing Entity Framework (Some links refer to Entity Framework 4.0. But you'll get the idea.): </p> <p><a href="http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/678b5871-bec5-4640-a024-71bd4d5c77ff" rel="nofollow noreferrer">http://social.msdn.microsoft.com/Forums/en/adodotnetentityframework/thread/678b5871-bec5-4640-a024-71bd4d5c77ff</a> </p> <p><a href="http://mosesofegypt.net/post/Introducing-Entity-Framework-Unit-Testing-with-TypeMock-Isolator.aspx" rel="nofollow noreferrer">http://mosesofegypt.net/post/Introducing-Entity-Framework-Unit-Testing-with-TypeMock-Isolator.aspx</a> </p> <p><a href="https://stackoverflow.com/q/2688840/337294">What is the way to go to fake my database layer in a unit test?</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload