Port from EF6 to EF Core - the Hybrid Approach
Two common approaches are to generate your database from code and use migrations, or generate your entities from the database using reverse-engineering. In the hybrid approach, you don't generate anything. Instead, you let the database and codebase evolve and use model configuration to keep the two in sync. This page contains some tips for success using the hybrid approach:
- First, read the guides for code as source of truth and database as source of truth to familiarize yourself with some of the considerations to be aware of.
- Because you won't be using migrations, there is no need to model sequences, non-primary indexes, constraints and index filters.
- An integration test suite is valuable in this approach for validating a proper handoff between code and the database as the code and database evolve.
- One approach to test that your mappings are correct is to generate a dummy database using a "throwaway" migration, then use a tool to compare the generated database to the actual database. You can quickly flag differences in schema and act on them.
- If you prefer, you can consider generating partial classes from the database and use extensions to those classes to configure your custom code.
Colaborați cu noi pe GitHub
Sursa pentru acest conținut poate fi găsită pe GitHub, unde puteți, de asemenea, să creați și să consultați probleme și solicitări de tragere. Pentru mai multe informații, consultați ghidul nostru pentru colaboratori.
Feedback
https://aka.ms/ContentUserFeedback.
În curând: Pe parcursul anului 2024, vom elimina treptat Probleme legate de GitHub ca mecanism de feedback pentru conținut și îl vom înlocui cu un nou sistem de feedback. Pentru mai multe informații, consultați:Trimiteți și vizualizați feedback pentru