I am using Database First with ASP.NET Core 2 and Entity Framework. When I initially use scaffold-dbcontext -connection....
in the Package Manager Console, all my classes are generated as expected and my context is created with the various modelBuilder.Entity
methods.
If I make a change to my database, and I attempt to keep my Database First designing, and I rerun scaffold-dbcontext
, my context is overwritten. This may not matter much as the models shouldn't change too much, but for example, I created a foreign key in a table that I already scaffolded. When I got EF to scaffold it my context only had those two new Entities (using -force
). All my old entities were gone.
I had to rescaffold everything -force to get back everything.
Should I be scaffolding to a separate -outputdir
and copy and paste to the original context and class? Don't I need all the Entities in the context to use them in my controllers?