DEV Community

Cover image for EF Core Update Model on Database First Project
João Osório
João Osório

Posted on

EF Core Update Model on Database First Project

Started on a software project that will run using an existing database. Went with a minimalistic structure and used the EF Core Tools, from the Package Manager Console in Visual Studio, to generate the database context and table model classes. Namely scaffold-dbcontext. Used the '-t' option to create just the model classes I would use. It went very well and development went on, business as usual.

As it turned out, I missed a table, so I had to add the model class for that and update the database context. Of course I thought that Visual Studio should have some tool our wizard like it had when using EDMX files. I was wrong, Entity Framework Core has not added support for EDMX generation.

As I had no business related code inside the model classes, or any special customization, the simplest scenario was to reverse engineer the model from the database again using scaffold-dbcontext with the '-Force' option. Mind that if you reverse engineer the model from the database again, any changes you've made to the files will be lost.

Nevertheless, if you're more into GUI than CLI, you should try out EF Core Power Tools. Check out the demo from .NET Conf 2020 on youtube.

Original post can be found here

Image created by vectorjuice - www.freepik.com

Discussion (0)