Hello friends and senior,
I have an doubt related to development approch code first & database approch, which one is better for development on which situation?
Like if I have already a product in asp.net or vb.net i wanted to buid same product at scrach in asp.net core then which one approch is better for me to developed my project,
plz tell me in breif.

sasikala sPosted Dec 23, 2024, 5:54 AM
Code First and Database First approaches in development often depends on your specific project requirements, existing infrastructure, and team preferences. Here’s a breakdown to help you decide:
Code First Approach
Database First Approach
Recommendation for Your Situation
Since you mentioned you have an existing product in ASP.NET or VB.NET and want to build it from scratch in ASP.NET Core, Database First might be the better approach if:
Tuhin PaulPosted Dec 21, 2024, 3:52 AM
Since you're rebuilding an existing product in Core, I would recommend a Database-First approach. This will allow you to:
- Leverage the existing database schema and relationships
- Focus on optimizing database performance
- Check for a smoother transition from the old system to the new one
But if you're planning to make significant changes to the database schema or want to take advantage of Core's automated testing and mocking features, a Code-First approach might be a better fit.
Sangeetha SPosted Dec 20, 2024, 8:25 AM
Code First Approach
Database First Approach
Since you mentioned you want to build the same product from scratch in ASP.NET Core and already have an existing application, consider the following:
If your existing database is stable and you want to ensure the new application mirrors the existing functionality, Database First might be the better option. This way, you can quickly scaffold the models and ensure you're working with the same schema as your existing product.
If you're looking to evolve the product and make significant changes to the data model, consider using Code First. This approach will allow you to define new entities and relationships that may not exist in the current database and easily manage changes over time.
Jayraj ChhayaPosted Dec 19, 2024, 6:02 AM
Hi Rahul Chauhan,
When deciding between Code First and Database First approaches in ASP.NET Core, it largely depends on your project requirements and existing infrastructure.
Code First is ideal if you prefer to define your data model in code and let Entity Framework create the database schema for you. This approach is beneficial when starting a new project or when you want to maintain full control over your codebase. It allows for easier version control and migrations, making it suitable for agile development.
On the other hand, Database First is more appropriate if you already have an existing database, such as your current ASP.NET or VB.NET product. This approach allows you to generate your data model from the existing database schema, which can save time and ensure consistency with your current data structure.
Given that you are looking to rebuild an existing product, Database First might be the better choice, as it allows you to leverage your existing database while transitioning to ASP.NET Core. However, if you plan to evolve the data model significantly, consider starting with Code First for greater flexibility.
Ultimately, the choice should align with your project goals and the level of control you wish to maintain over your data model.
Jignesh KumarPosted Dec 19, 2024, 4:09 AM
Hello Rahul,
It entirely depends on the project requirements and how you intend to build your system. When planning to migrate an old project to a new tech stack, consider the following points,
If you're transitioning from an existing ASP.NET or VB.NET product and wish to rebuild it in ASP.NET Core, the Database First approach may be a better choice if:
On the other hand, the Code First approach may be more suitable if: