views:

55

answers:

4

I'm looking for an utility class to generate fake entity instances at runtime. I'm implementing a ASP.NET MVC3 website using EF4 with a code-first approach, so I'd like to run the site before creating any database. The fake instances should contain valid data (hopefully reflecting the various DataAnnotation attributes used in each class definition).

Thanks anyone for supporting this.

A: 

The place to start is to look at the "Seed Data" example in this post: http://blogs.msdn.com/b/adonet/archive/2010/09/02/ef-feature-ctp4-dbcontext-and-databases.aspx

This will allow you to write the necessary routines to populate your test data

Clicktricity
Thanks Clicktricity, this is a good post, but I'm looking for an in-memory fake
Hemme
No problem. In that case you need to create a fake data context and implement IDbSet for each of your entities. There is a good example of this here: http://romiller.com/2010/09/07/ef-ctp4-tips-tricks-testing-with-fake-dbcontext/
Clicktricity
A: 

Hi Hemme,

We use Console Apps in our projects to generate anything we need for testing are to start an install.

abarr
A: 

Have you looked at SQLite?

Ryan
A: 

Are you looking for a Framework like FakeItEasy?

Description taken from the website:

A .Net dynamic fake framework for creating
all types of fake objects, mocks, stubs etc.

  * Easier semantics, all fake objects are
    just that - fakes - the use of the fakes
    determines whether they're mocks or stubs.
  * Context aware fluent interface guides the developer.
  * Full VB.Net support. 

Designed for ease of use and for compatibility with both C# and VB.Net. 
Bobby