Today, the .NET data team announces the third preview release of EF Core 7.0 (EF7). In addition to bug fixes and foundation work for larger features, we are pleased to announce the initial preview of scaffolding (database-first) templates. This preview also includes changes to the update pipeline to improve performance and streamline the generated SQL, and support for TPC in migrations. Be sure to read the full plan for EF7 to learn what’s on the roadmap.
You can also view the full list of issues addressed in EF7 Preview 3.
Improvements to the update pipeline
Several improvements to the update pipeline are now part of Preview 3, including:
- Improve SQL Server insertion logic (also make RETURNING the default INSERT strategy for retrieving db-generated values for other providers).
- Use RETURNING/OUTPUT clause for UPDATE/DELETE
- Refactor ReaderModificationCommandBatch
- Reimplement MaxBatchSize as a pre-check
Take control of your DbContext
Preview 3 introduces the ability to control how EF7 reverse engineers or scaffolds classes for database-first projects using T4 templates. Do you prefer “null bang” setters? Property initializers? Constructor initialization? All these customizations are now possible. In fact, you are not limited to generating the “traditional” DbContext and entity classes. Anything is possible, including using the templates to generate documentation.
The best way to learn about this new feature is to watch our recent community standup: Database-first with T4 templates in EF7. The video begins with an introduction to T4 templates for those of you who are not familiar with them. The EF7 feature is introduced about 23 minutes in. In addition to generating custom code, the demo shows how to create markdown using Mermaid syntax to generate ERD diagrams.
Code like this:
```mermaid
erDiagram
ORDERMASTER ||--o{ ORDERDETAIL : owns
ORDERDETAIL ||--|{ LINE-ITEM : contains
ORDERMASTER }|..|{ CUSTOMER : uses
```
Produces diagrams like this: