-
Notifications
You must be signed in to change notification settings - Fork 2k
Description
Type of issue
Typo
Description
- 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
Document Version Independent Id
b38b9d14-6bad-12e0-8d2d-24b50bc4977e
Platform Id
68574f15-affa-b8c3-795e-2211c5bf6d5c