Creating seed model from data already in DB

Posted by Nick Brown on Stack Overflow See other posts from Stack Overflow or by Nick Brown
Published on 2012-07-02T02:57:54Z Indexed on 2012/07/02 3:16 UTC
Read the original article Hit count: 188

Is there a way to convert data in an existing database into objects that can easily be put into a seed method?

Essentially I'd like to let some people add lines to my DB via a form and then convert that into an object that I can re-seed the DB anytime I need to make changes.

The database itself is created via code-first using the following model:

public class Combo
{
    public int Id { get; set; }
    public string MainPrefix { get; set; }
    public string MainDescriptor { get; set; }
    public string MainDish { get; set; }
    public string Connector { get; set; }
    public string SecondaryDescriptor { get; set; }
    public string SecondaryDish { get; set; }
}

© Stack Overflow or respective owner

Related posts about database

Related posts about asp.net-mvc-3