问题
My textbook says:
dotnet ef dbcontext scaffold "Server (localdb)\MSSQLLocalDB;Database=XXX" "Microsoft.EntityFrameworkCore.SqlServer" --output-dir "Models/Scaffold" --context ScaffoldContext --force --no-build
--no-build argument prevents the project from being built before the scaffolding process is performed. It is easy to get into a situation where the scaffolding process generates a data model that is out of sync with the rest of the application, such as controllers and views. Entity Framework Core tries to build the project by default before scaffolding a database, and a failed build—commonly because a property or data model class has been removed—will prevent the scaffolding process from being performed
I kind of get the idea, but I'm still confused by the description. If the project tries to build the project by default before scaffolding a database, there is no modifications in data model since the scaffolding hasn't started yet, and if there is a failed build, that means there are existing errors in the application and we have to rectify them, then do the scaffolding. The 'out of sync' situation only exists after the scaffolding process is finished, but even a failed build happens, the scaffolding process has been finished anyway, we just need to simply rebuild the project. So how can the scaffolding process get prevented from being performed?
To summary, the textbook says "a failed build—commonly because a property or data model class has been removed" (my note here: this can only happen after scaffolding process finished and therefore some properties were removed from data model)
which contradicted by
"(a failed build because of properties removal) will prevent the scaffolding process from being performed"
so how can sth to be prevented from happening if it has happened already?
来源:https://stackoverflow.com/questions/57526519/no-build-prevents-the-scaffolding-process-from-being-performed