-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Milestone
Description
No entities end up being tracked.
Repro:
public class BloggingContext : DbContext
{
public DbSet<Blog> Blogs { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=LoadAsyncTest;Trusted_Connection=True;");
}
public class Blog
{
public int Id { get; set; }
public string Title { get; set; }
}
public class Program
{
public static void Main()
{
Task.Run(async () =>
{
await MainAsync();
}).Wait();
}
public static async Task MainAsync()
{
using (var context = new BloggingContext())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
context.AddRange(new Blog(), new Blog());
await context.SaveChangesAsync();
}
using (var context = new BloggingContext())
{
await context.Blogs.LoadAsync();
Console.WriteLine(context.ChangeTracker.Entries().Count());
}
}
}
Output is 0; expected output is 2.
When run with Load instead of LoadAsync, output is 2 as expected.
Note that there are currently zero tests for LoadAsync.