GraemeMiller
GraemeMiller

Reputation: 12253

How Do I Easily Populate Entity Framework Context Initializer With Test Data?

Is there any way to generate a context initializer from database entries etc?

I am using Code First 4.2 and want to have a consistent set of data to start my application.

I have a large context I want to populate and I don't want to manually type it out. Also is there anyway to generate random data etc that meets the requirements of the entities?

Upvotes: 2

Views: 1348

Answers (1)

Wouter de Kort
Wouter de Kort

Reputation: 39898

One thing you could use are the DataGeneration plans that the DatabaseProject has. We use them to generate our test data with some meaningful values.

Here you can find a walktrough.

Or you could use Sql Server Management Studio to script the data that is currently in your database and execute that script in your Initializer.

Upvotes: 3

Related Questions