dotnet / dotnet/EntityFramework.Docs

Docs seting up people to fail

Open
#2,103 1 comment 0 reactions 0 assignees View on GitHub
area-global
Dominant language
Mermaid
Stars
1.7k
Forks
2k
Avg merge
7d 23h
Merged PRs (30d)
16

Description

This issue tracker is for ***documentation***

For ***product*** issues, use https://github.com/aspnet/EntityFramework/issues

Hi,

First of i love EF and recommend it to everyone but the docs about relations are setting people up to fail.

Under the section **adding a related enitity** the query loads all the posts only to insert one more into the database.

```C#
using (var context = new BloggingContext())
{
var blog = context.Blogs.Include(b => b.Posts).First();
var post = new Post { Title = "Intro to EF Core" };

blog.Posts.Add(post);
context.SaveChanges();
}
```

If the documentation is going to teach people worst practices then it needs to educate about the problem and how to overcome it.

I get that the motivation is to show EF makes data access code simple and object oriented but this in this case it is misleading potential new user that this code is just fine and there is no need to do it any other way and the problem in their apps will show only in a year.

I expect the official documentation to teach new user about performance traps like this and how to avoid them and not be a primary source of performance traps.

The above code is the perfect place to explain that the object oriented example is not recommended when there will be a lot of content and give an example of inserting by assigning an ID.

There seems to be a whole ecosystem of people who hate EF and ORMs because they got burned by assumptions about how easy it is do things the object oriented way and i think the official docs should not setup people to get burned.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.