Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's New for preview 5 #4744

Merged
merged 2 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion entity-framework/core/extensions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ These packages are designed to integrate directly with EF Core to expose various

Enhance the local development experience by simplifying the management of your cloud-native app's configuration and interconnections. For EF Core: 8.

[Website](https://learn.microsoft.com/dotnet/aspire/get-started/aspire-overview) | [GitHub repository](https://github.com/dotnet/aspire) | [NuGet](https://www.nuget.org/profiles/aspire)
[Website](/dotnet/aspire/get-started/aspire-overview) | [GitHub repository](https://github.com/dotnet/aspire) | [NuGet](https://www.nuget.org/profiles/aspire)

### HotChocolate

Expand Down
1 change: 0 additions & 1 deletion entity-framework/core/learn-more/community-standups.md
Original file line number Diff line number Diff line change
Expand Up @@ -1591,7 +1591,6 @@ Featuring:
Links:

- Blog: [Oracle EF Core 3.1 Production Release](https://medium.com/oracledevs/oracle-ef-core-3-1-production-release-9e470eaf3d03)
- Blog: [Seeding data in EF Core using SQL scripts](https://dejanstojanovic.net/aspnet/2020/september/seeding-data-in-ef-core-using-sql-scripts/)
- Blog: [Announcing Entity Framework Core (EFCore) 5.0 RC1](https://devblogs.microsoft.com/dotnet/announcing-entity-framework-core-efcore-5-0-rc1/)
- Docs: [Migrations Overview](xref: core/managing-schemas/migrations/index)
- Docs: [EF Core daily builds](https://aka.ms/ef-daily-builds)
Expand Down
309 changes: 307 additions & 2 deletions entity-framework/core/what-is-new/ef-core-9.0/whatsnew.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;

public static class CosmosDiagnosticsSample
{
public static void Cosmos_diagnostics()
public static async Task Cosmos_diagnostics()
{
Console.WriteLine($">>>> Sample: {nameof(Cosmos_diagnostics)}");
Console.WriteLine();

Helpers.RecreateCleanDatabase();
Helpers.PopulateDatabase();
await Helpers.RecreateCleanDatabase();
await Helpers.PopulateDatabase();

using var context = new ShapesContext();

Expand All @@ -30,23 +30,23 @@ public static void Cosmos_diagnostics()
InsertedOn = DateTime.UtcNow
};
context.Add(triangle);
context.SaveChanges();
await context.SaveChangesAsync();
#endregion

Console.WriteLine();
Console.WriteLine("Query diagnostic events:");
Console.WriteLine();

#region QueryEvents
var equilateral = context.Triangles.Single(e => e.Name == "Equilateral");
var equilateral = await context.Triangles.SingleAsync(e => e.Name == "Equilateral");
#endregion

Console.WriteLine();
Console.WriteLine("Find diagnostic events:");
Console.WriteLine();

#region FindEvents
var isosceles = context.Triangles.Find("Isosceles", "TrianglesPartition");
var isosceles = await context.Triangles.FindAsync("Isosceles", "TrianglesPartition");
#endregion

Console.WriteLine();
Expand All @@ -55,7 +55,7 @@ public static void Cosmos_diagnostics()

#region UpdateEvents
triangle.Angle2 = 89;
context.SaveChanges();
await context.SaveChangesAsync();
#endregion

Console.WriteLine();
Expand All @@ -64,23 +64,23 @@ public static void Cosmos_diagnostics()

#region DeleteEvents
context.Remove(triangle);
context.SaveChanges();
await context.SaveChangesAsync();
#endregion

Console.WriteLine();
}

public static class Helpers
{
public static void RecreateCleanDatabase()
public static async Task RecreateCleanDatabase()
{
using var context = new ShapesContext(quiet: true);

context.Database.EnsureDeleted();
context.Database.EnsureCreated();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
}

public static void PopulateDatabase()
public static async Task PopulateDatabase()
{
using var context = new ShapesContext(quiet: true);

Expand All @@ -94,7 +94,7 @@ public static void PopulateDatabase()
};

context.AddRange(triangles);
context.SaveChanges();
await context.SaveChangesAsync();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;

public static class CosmosImplicitOwnershipSample
{
public static void Cosmos_models_use_implicit_ownership_by_default()
public static async Task Cosmos_models_use_implicit_ownership_by_default()
{
Console.WriteLine($">>>> Sample: {nameof(Cosmos_models_use_implicit_ownership_by_default)}");
Console.WriteLine();

using (var context = new FamilyContext())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();

context.AddRange(
new Family
Expand Down Expand Up @@ -44,7 +45,7 @@ public static void Cosmos_models_use_implicit_ownership_by_default()
LastName = "Wakefield",
Parents =
{
new() { FamilyName = "Wakefield", FirstName = "Robin" },
new() { FamilyName = "Wakefield", FirstName = "Robin" },
new() { FamilyName = "Miller", FirstName = "Ben" }
},
Children =
Expand All @@ -69,14 +70,14 @@ public static void Cosmos_models_use_implicit_ownership_by_default()
IsRegistered = true
});

context.SaveChanges();
await context.SaveChangesAsync();
}

Console.WriteLine();

using (var context = new FamilyContext())
{
var families = context.Families.ToList();
var families = await context.Families.ToListAsync();

Console.WriteLine();

Expand All @@ -96,10 +97,10 @@ public class Family
{
[JsonPropertyName("id")]
public string Id { get; set; }

public string LastName { get; set; }
public bool IsRegistered { get; set; }

public Address Address { get; set; }

public IList<Parent> Parents { get; } = new List<Parent>();
Expand Down Expand Up @@ -153,7 +154,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
modelBuilder.Entity<Family>().HasPartitionKey(e => e.LastName);
#endregion
}

// Never called; just for documentation.
private void OldOnModelCreating(ModelBuilder modelBuilder)
{
Expand All @@ -167,7 +168,7 @@ private void OldOnModelCreating(ModelBuilder modelBuilder)
.OwnsMany(c => c.Pets);

modelBuilder.Entity<Family>()
.OwnsOne(f => f.Address);
.OwnsOne(f => f.Address);
#endregion
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;

public static class CosmosPrimitiveTypesSample
{
public static void Collections_and_dictionaries_of_primitive_types()
public static async Task Collections_and_dictionaries_of_primitive_types()
{
Console.WriteLine($">>>> Sample: {nameof(Collections_and_dictionaries_of_primitive_types)}");
Console.WriteLine();

Helpers.RecreateCleanDatabase();
await Helpers.RecreateCleanDatabase();

#region Insert
using var context = new BooksContext();
Expand All @@ -35,27 +36,27 @@ public static void Collections_and_dictionaries_of_primitive_types()
};

context.Add(book);
context.SaveChanges();
await context.SaveChangesAsync();
#endregion

#region Updates
book.Quotes.Add("Pressing the emergency button lowered the rods again.");
book.Notes["48"] = "Chiesa d'Oro";

context.SaveChanges();
await context.SaveChangesAsync();
#endregion

Console.WriteLine();
}

public static class Helpers
{
public static void RecreateCleanDatabase()
public static async Task RecreateCleanDatabase()
{
using var context = new BooksContext(quiet: true);

context.Database.EnsureDeleted();
context.Database.EnsureCreated();
await context.Database.EnsureDeletedAsync();
await context.Database.EnsureCreatedAsync();
}
}

Expand Down
6 changes: 3 additions & 3 deletions samples/core/Miscellaneous/NewInEFCore6.Cosmos/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ public class Program
public static async Task Main()
{
// Note: These samples requires the Cosmos DB emulator to be installed and running
CosmosPrimitiveTypesSample.Collections_and_dictionaries_of_primitive_types();
await CosmosPrimitiveTypesSample.Collections_and_dictionaries_of_primitive_types();
await CosmosQueriesSample.Cosmos_queries();
CosmosDiagnosticsSample.Cosmos_diagnostics();
await CosmosDiagnosticsSample.Cosmos_diagnostics();
CosmosModelConfigurationSample.Cosmos_configure_time_to_live();
await CosmosModelConfigurationSample.Cosmos_configure_time_to_live_per_instance();
CosmosImplicitOwnershipSample.Cosmos_models_use_implicit_ownership_by_default();
await CosmosImplicitOwnershipSample.Cosmos_models_use_implicit_ownership_by_default();
CosmosMinimalApiSample.Add_a_DbContext_and_provider();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.5.24251.2">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.6.24304.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.5.24251.2">
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.6.24304.2">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0-preview.5.24251.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0-preview.5.24251.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tasks" Version="9.0.0-preview.5.24251.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0-preview.6.24304.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0-preview.6.24304.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tasks" Version="9.0.0-preview.6.24304.2" />
</ItemGroup>

<ItemGroup>
Expand Down
Loading
Loading