This project is read-only.


UpForGrabs: Export data as C# / VB format to use them in EF Code First's seed data


Some times, sample data is important but boring to generate due to many related tables. So, in Entity Framework Code First, I think it's an elegant way to insert them in DropCreateDatabaseIfModelChanges::Seed().

But is there a way to export existing data from database back to a string as C# / VB sentences that insert poco objects?

If it works, we may use it to backup data gracefully, or save to multiple .cs by scenes, switch them as needed to better our test, etc.


var students = new List<Student>
new Student { FirstMidName = "Carson",   LastName = "Alexander", },
new Student { FirstMidName = "Meredith", LastName = "Alonso",    },
new Student { FirstMidName = "Arturo",   LastName = "Anand",     },
// ...
students.ForEach(s => context.Students.Add(s));
Closed Dec 13, 2016 at 8:32 PM by RoMiller
EF Team Triage: We are transitioning this project to GitHub ( As part of this transition we are bulk closing a large number of issues in order that our new issue tracker will accurately reflect the work that our team is planning to complete on the EF6.x code base.

Moving forwards, our team will be fixing bugs, implementing small improvements, and accepting community contributions to the EF6.x code base. Larger feature work and innovation will happen in the EF Core code base ( Closing a feature request in the EF6.x project does not exclude us implementing the feature in EF Core. In fact, a number of popular feature requests for EF have already been implemented in EF Core (alternate keys, batching in SaveChanges, etc.).

This is a bulk message to indicate that this issue was closed and not ported to the new issue tracker. The reasons for not porting this particular issue to GitHub may include:
  • It was a bug report that does not contain sufficient information for us to be able to reproduce it
  • It was a question, but sufficient time has passed that it's not clear that taking the time to answer it would provide value to the person who asked it
  • It is a feature request that we are realistically not going to implement on the EF6.x code base
    Although this issue was not ported, you may still re-open it in the new issue tracker for our team to reconsider ( We will no longer be monitoring this issue tracker for comments, so please do not reply here.


RoMiller wrote Aug 14, 2012 at 6:22 PM

Should really support migrations rather than initializer.