Projections With Full Types Not Fixing Up Navigations on Sqlite and SQL Server
See original GitHub issueI’ve searched for a related issue as well as blog posts/docs and am not finding anything. I know it’s out there somewhere but have to stop looking!
Also related to https://github.com/aspnet/EntityFramework/issues/4007
Steps to reproduce
using System.Collections.Generic;
using System.Linq;
using Microsoft.EntityFrameworkCore;
namespace ProjectionProblem
{
public class Parent
{
public Parent()
{
Children = new List<Child>();
}
public int Id { get; set; }
public string Description { get; set; }
public List<Child> Children { get; set; }
}
public class Child
{
public int Id { get; set; }
public string Description { get; set; }
}
public class MyContext : DbContext
{
public DbSet<Parent> Parents { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite("Data source=ProjectionProblem.db");
}
}
public class Program
{
private static void Main(string[] args)
{
using (var context = new MyContext())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
var parent = new Parent {Description = "Parent1"};
parent.Children.Add(new Child {Description = "Child1"});
parent.Children.Add(new Child {Description = "Child2"});
context.Parents.Add(parent);
context.SaveChanges();
}
using (var context2 = new MyContext())
{
var newtype = context2.Parents.Select(p => new {Parent = p, p.Children}).ToList();
}
}
}
}
The issue
Navigations not being fixed up in results. newtype.Children has the child objects, but newtype.Parent.Children is empty.
Further technical details
EF Core version: 1.1 Operating system: Visual Studio version: vs2015 but really not applicable
Other details about my project setup:
Issue Analytics
- State:
- Created 7 years ago
- Comments:31 (13 by maintainers)
Top Results From Across the Web
Exception when using EF Core InMemory and a projection ...
In our real code, using the SQL Server provider (at runtime) works and does not error, as with SQLite. Using the InMemory provider...
Read more >Efficient Querying - EF Core
Performance guide for efficient querying using Entity Framework Core.
Read more >Complex Query Operators - EF Core
Language Integrated Query (LINQ) contains many complex operators, which combine multiple data sources or does complex processing. Not all LINQ ...
Read more >Entity Framework Core 5 - Pitfalls To Avoid and Ideas to Try
In this post, we'll look at some pitfalls and ideas EF Core users like yourself may want to consider when developing an application....
Read more >Save data using SQLite
Saving data to a database is ideal for repeating or structured data, such as contact information. This page assumes that you are familiar...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Closing as fixed in 2.0
Thanks for taking the time to try this out!