-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add auto-compiled models to What's New (#4701)
* Add auto-compiled models to What's New * API review changes
- Loading branch information
1 parent
4aac6af
commit 2a9b430
Showing
10 changed files
with
261 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
samples/core/Miscellaneous/NewInEFCore9.CompiledModels/App/App.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace/> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.4.24205.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Model\Model.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
13 changes: 13 additions & 0 deletions
13
samples/core/Miscellaneous/NewInEFCore9.CompiledModels/App/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using NewInEfCore9; | ||
|
||
public class Program | ||
{ | ||
public static void Main() | ||
{ | ||
Console.WriteLine("Starting application..."); | ||
|
||
using var context = new BlogsContext(); | ||
|
||
Console.WriteLine($"Model loaded with {context.Model.GetEntityTypes().Count()} entity types."); | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
samples/core/Miscellaneous/NewInEFCore9.CompiledModels/Model/BlogsContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
using Microsoft.EntityFrameworkCore.Diagnostics; | ||
|
||
namespace NewInEfCore9; | ||
|
||
public class BlogsContext : DbContext | ||
{ | ||
public DbSet<Blog> Blogs => Set<Blog>(); | ||
|
||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) | ||
=> optionsBuilder | ||
.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=EF9CompiledModels;ConnectRetryCount=0") | ||
.LogTo(_ => Console.WriteLine(">> EF is building the model..."), [CoreEventId.ShadowPropertyCreated]) | ||
.EnableSensitiveDataLogging(); | ||
} |
16 changes: 16 additions & 0 deletions
16
samples/core/Miscellaneous/NewInEFCore9.CompiledModels/Model/EntityTypes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace NewInEfCore9; | ||
|
||
public class Blog | ||
{ | ||
public int Id { get; set; } | ||
|
||
public ICollection<Post> Posts { get; } = new List<Post>(); | ||
} | ||
|
||
public class Post | ||
{ | ||
public int Id { get; set; } | ||
public string? Title { get; set; } | ||
|
||
public Blog Blog { get; set; } = null!; | ||
} |
39 changes: 39 additions & 0 deletions
39
samples/core/Miscellaneous/NewInEFCore9.CompiledModels/Model/Model.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>library</OutputType> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<RootNamespace>NewInEfCore9</RootNamespace> | ||
<LangVersion>Preview</LangVersion> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup> | ||
<EFOptimizeContext>true</EFOptimizeContext> | ||
<EFStartupProject>..\App\App.csproj</EFStartupProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="9.0.0-preview.4.24205.3"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="9.0.0-preview.4.24205.3" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="9.0.0-preview.4.24205.3" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tasks" Version="9.0.0-preview.4.24205.3" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="System.ComponentModel.DataAnnotations" /> | ||
<Using Include="System.ComponentModel.DataAnnotations.Schema" /> | ||
<Using Include="System.Data.Common" /> | ||
<Using Include="System.Linq.Expressions" /> | ||
<Using Include="System.Reflection" /> | ||
<Using Include="System.Runtime.CompilerServices" /> | ||
<Using Include="Microsoft.EntityFrameworkCore" /> | ||
<Using Include="Microsoft.Extensions.Logging" /> | ||
<Using Include="Microsoft.Extensions.DependencyInjection" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters