locked
Can i use database first approach with entity framework inside asp.net core RRS feed

  • Question

  • User-540818677 posted

    I want to start a new asp.net core MVC web project, but i am but sure if i can follow the database first approach? by creating the database inside my sql server >> then map the database inside my application using entity framework (as we used to do in asp.net mvc-5)? Thanks

    Tuesday, May 5, 2020 2:47 PM

All replies

  • User1120430333 posted

    It's called the 'existing database approach'.

    https://www.entityframeworktutorial.net/efcore/create-model-for-existing-database-in-ef-core.aspx

    You can also use the Power Tools and Reverse Engineer for an existing database.

     https://erikej.github.io/EFCorePowerTools/index.html

    Tuesday, May 5, 2020 3:12 PM
  • User-474980206 posted

    Yes, you can database first. See the scaffolding tools:

       https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding

    you can also google ef core database first for tutorials

    Tuesday, May 5, 2020 3:15 PM
  • User-540818677 posted

    Yes, you can database first. See the scaffolding tools:

       https://docs.microsoft.com/en-us/ef/core/managing-schemas/scaffolding

    you can also google ef core database first for tutorials

    thanks for the reply, so the approach is different from what we use to do in asp.net mvc-5, where we map the tables using ado.net EF ?

    Tuesday, May 5, 2020 4:00 PM
  • User-474980206 posted

    no its the same as EF 6. you can manually map the tables, or use scaffolding to generate the classes and mapping.

    Tuesday, May 5, 2020 4:10 PM
  • User-540818677 posted

    no its the same as EF 6. you can manually map the tables, or use scaffolding to generate the classes and mapping.

    so i can still generate .edmx class to map the database tables? i have not find any link which talk about manually mapping the database tables inside asp.net core..

    Tuesday, May 5, 2020 6:49 PM
  • User1120430333 posted

    bruce (sqlwork.com)

    no its the same as EF 6. you can manually map the tables, or use scaffolding to generate the classes and mapping.

    so i can still generate .edmx class to map the database tables? i have not find any link which talk about manually mapping the database tables inside asp.net core..

    There is no edmx in .NET Core. If you have done the scaffolding of an existing database schema, they you will clearly see what is happening in the created Model folder that contains the Dbcontext. Anything you knew about using EF database first prior to EF Core. you can toss it out the window. :)

    The only thing that comes close to what Ef database first was doing prior to EF Core is the EF Core Power tools that has a graphical user interface that allows one to select the tables for the generated model and dbcontext  code from  an existing database, which is similar to the EF 6 and prior versions of EF for database first where there is a graphical user interface that the developer used to make the table selection of the tables he or she wanted from an existing database for the edmx class generated model.

    Wednesday, May 6, 2020 1:53 AM
  • Wednesday, May 6, 2020 5:05 AM