I'm playing around with EF and have a model set up, generated from a database. The model is code-only, no designers.
I added a field to one of my database tables.
Is there any easy way I can "regenerate" the model code?
I guess if I had used the designers, this would be easier, and I can find info on migrating the opposite way (add a model property and get a migration to update the db), but nothing about how I can propagate changes from the DB through to the model.
I supposed I could do it manually, but that hardly seems ideal...
One option is just delete the auto generated classes from the project and once again generate them. While following this approach only thing we need to make sure that is, we should give the same name for the data model(class name which inherits from DbContext ) as the previous one.
I remember doing something like this a while back ago - its called reverse engineer code first. Basically it looks at the current database and creates the POCO classes for you based on that database. I've done it both when creating a new project as this tutorial suggests: https://msdn.microsoft.com/en-us/library/jj200620.aspx
and I've also done it using an older version of this tool: https://visualstudiogallery.msdn.microsoft.com/72a60b14-1581-4b9b-89f2-846072eff19d
In the end, you may find that Jaydeep's method of deleting and starting over is easiest.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With