EF Core 2.1 CRUD Best Practices, especially with related data??

So I have been reading everything I can about EF Core 2.1 and still cannot figure out best practices for CRUD operations using ASP.NET Core 2.1 and EF Core 2.1. The tutorials on MSDN are still in 2.0, when it comes to using EF Core 2.1 with MVC, WebAPI, and Razor Pages.

Does anyone have a surefire way to do CRUD operations with relationships in EF Core 2.1? I would love to see a sample github app or tutorial.

A few things I’ve come across

Overposting: TryUpdateModalAsync vs converting to ViewModels (and how to convert back and forth)

When to catch concurrency exceptions

Editing: State = EntityState.Modified vs context.Update

When to attach vs adding

Dealing with related data (esp many-to-many relationships, removing the relationship without removing the data)

submitted by /u/headyyeti
[link] [comments]

Leave a Reply