2

I am learning EF and found two different methods for entity model file creation.

The first method uses ADO.NET Entity Data Model Template in Visual Studio which create a .edmx file, dbcontext file and .tt file.

The second method I found at https://learn.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db uses Scaffolding technique which uses a command like below

Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

The second method just create the classes for the db tables and the dbcontext file but no .edmx file or .tt files metadata information being created. But the first method adds a connectionstring in app.config file with metadata information as well.

My doubt is what is the fundamental difference between these two? Are both methods acceptable in a development environment?

Your thoughts and inputs are highly appreciated.

Thanks Peter

Steve Greene
  • 12,029
  • 1
  • 33
  • 54
  • If you are new to EF i would recommend you to go straight for EF code first, all the rest is depreciated i heard. – Antoine Pelletier Oct 11 '17 at 15:47
  • You want to look into [Code First vs Model First](https://stackoverflow.com/questions/5446316/code-first-vs-model-database-first). Code First also comes with a tool to reverse engineer an existing database. BTW, your link is for EF Core which does not support Model First with EDMX. Finally, scaffolding really has nothing to do with it other than it can help create the controllers and such on the MVC side. – Steve Greene Oct 11 '17 at 21:33

0 Answers0