Working with databases.
WHAT IT PROVIDES
Mapping between classes and database tables, with queries written in code.
WHAT MIGRATIONS PROVIDE
Versioned schema changes, applied in order.
WHAT TO COMMIT
Migrations, with the application.
WHAT TO NEVER DO
Change the database manually and leave migrations behind.
WHAT THE COMMONEST PERFORMANCE FAULT IS
Issuing one query per item in a loop.
HOW IT HAPPENS
Accessing a related property inside an iteration, where each access triggers a query.
WHAT SOLVES IT
Loading related data explicitly, in one query.
WHAT ELSE TO WATCH
Retrieving entire entities where a few columns suffice Tracking entities that are only read Queries executed client-side because they could not be translated
WHAT TO DO ABOUT THAT LAST ONE
Establish where the boundary is, and keep filtering on the database side.
WHAT TO PROFILE
The actual queries produced.
WHY
The code and the resulting query can differ substantially.
WHAT TO USE FOR COMPLEX QUERIES
Direct queries, where the abstraction adds nothing.
WHAT TO TEST
Migrations, against a copy of production data.