Database-first approach on Entity Framework Core

Just a quick tip for those of you disappointed by the lack of a UI-based option to go database-first on Entity Framework Core.

The feature is still there (more or less…), you have to open the Package Manager Console on Visual Studio and use the Scaffold-DbContext command to generate the data context.

Unlike the old (?) data context (EDMX), the Scaffold-DbContext command generates a standalone data context class and every new execution of the command recreates/overwrites the existing files, also overwriting every single change that you manually did after the scaffolding operation: this is clearly not so database-first-friendly, don’t you think?

So be careful about when it’s the right time to scaffold your data context.

The documentation talks about reverse engineering (of your existing database), and the database-first term seems to be officially gone.
Honestly I don’t agree with this vision, but you know: when Microsoft decides……

I write mainly about IT related things.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store