locked
Does Database First Code First supported in asp.net core? RRS feed

  • Question

  • User2070555482 posted

    Hi Good day,

    I'am a .net developer and i use .net framework 4.6. I always used database first code first of entity framework I like that stuff beacuse it cant create edmx file like database first did and create a model class like what created in code first and that was pretty smoth and clean for me. Another thing is when I update my database (eg. add table or column) only thing i can do is to create a class same structure to may database table and put an attribute for eg ( [Table("SampleTable")]  ) then it automatically mapped. 

    Now my question is it is possible to do this stuff in .net core? I'am planning to migrate my web app. Is this another way ? Please guide for this one . Thank you

    Wednesday, July 25, 2018 3:41 AM

Answers

  • User1120430333 posted

    There is no more edmx using EF core. So in my opinion,  it really doesn't matter if you use DB first or code first. I have not used EF Core code first, but I am using EF Core DB First if ASP.NET Core MVC solution based on what I learned from this tutorial.  EF Core DB first still allows one to point to the an existing database schema to create the context class representing the virtual object model. 

    https://www.codeproject.com/Articles/1209903/Getting-Started-with-Entity-Framework-Core-Databas

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 25, 2018 10:35 AM

All replies

  • User1120430333 posted

    There is no more edmx using EF core. So in my opinion,  it really doesn't matter if you use DB first or code first. I have not used EF Core code first, but I am using EF Core DB First if ASP.NET Core MVC solution based on what I learned from this tutorial.  EF Core DB first still allows one to point to the an existing database schema to create the context class representing the virtual object model. 

    https://www.codeproject.com/Articles/1209903/Getting-Started-with-Entity-Framework-Core-Databas

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, July 25, 2018 10:35 AM
  • User-1034726716 posted

    is it is possible to do this stuff in .net core?

    Yes and I wrote a getting started tutorial about it here: Getting Started with Entity Framework Core - Database First Development

    One thing to keep in mind is that the old-fashioned Entity Framework designer (.EDMX) isn’t supported in ASP.NET Core 1.1. Instead you need need to use the CLI commands to generate classes/models from your existing database.

    Tuesday, July 31, 2018 2:20 PM
  • User-2054057000 posted

    Gone are the days of .EDMX file in ASP.NET Core MVC. This is done becuase .EDMX file is a burden and difficult to handle, also it gets corrupted many times during development. 

    Database First Approach

    Database-First Approach is supported in EF Core but it is not strong enough. Microsoft has now put the emphasis on Code-First Approach.

    Code First Approach

    Code-First Approach in Entity Framework is the way you now work on EF Core. You create the classes, then put the required field, key, relationship using Fluent API or Data Annotation and then do the migrations. Migration will create your database with tables according to your classes. 

    Code-First is very strong in EF core and working is very simple. 

    I would strongly suggest you to follow the Code-First approach only. 

    Friday, August 24, 2018 10:25 AM