Skip to content

EF Core in Action: A Complete CRUD Journey #5128

@24smen037-blip

Description

@24smen037-blip

Type of issue

Typo

Description

  1. Create
    csharp
    db.Add(new Blog { Url = "http://blogs.msdn.com/adonet" });
    await db.SaveChangesAsync();
    Adds a new Blog entity to the database with the specified URL.

SaveChangesAsync() commits the change.
2. Read
csharp
var blog = await db.Blogs
.OrderBy(b => b.BlogId)
.FirstAsync();
Queries the Blogs table and retrieves the first blog ordered by BlogId.
3. Update
csharp
blog.Url = "https://devblogs.microsoft.com/dotnet";
blog.Posts.Add(
new Post { Title = "Hello World", Content = "I wrote an app using EF Core!" });
await db.SaveChangesAsync();
Updates the blog’s URL.

Adds a new Post to the blog’s Posts collection.

Saves the changes to the database.
4. Delete
csharp
db.Remove(blog);
await db.SaveChangesAsync();
Removes the blog (and its related posts, if cascade delete is configured).

Saves the deletion to the database.

Page URL

https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli

Content source URL

https://github.com/dotnet/EntityFramework.Docs/blob/main/entity-framework/core/get-started/overview/first-app.md

Document Version Independent Id

b38b9d14-6bad-12e0-8d2d-24b50bc4977e

Platform Id

68574f15-affa-b8c3-795e-2211c5bf6d5c

Article author

@Rick-Anderson

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions