-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Problem with LazyLoading and TPH #14039
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
punted-for-3.0
type-bug
Milestone
Comments
Repros on 2.1 and 2.2 preview3.
Minimal repro: using System;
using System.Linq;
using Microsoft.EntityFrameworkCore;
public abstract class Base
{
public Guid Id { get; set; }
}
public class Company : Base
{
public string CompanyName { set; get; }
}
public class Person : Base
{
public DateTime Birthday { set; get; }
public virtual Company Company { set; get; }
}
public class BloggingContext : DbContext
{
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseLazyLoadingProxies()
.UseSqlServer(@"Server=(localdb)\mssqllocaldb;Database=Test;ConnectRetryCount=0");
public DbSet<Person> Persons { set; get; }
public DbSet<Company> Companies { set; get; }
public DbSet<Base> Bases { set; get; }
public class Program
{
public static void Main()
{
using (var context = new BloggingContext())
{
context.Database.EnsureDeleted();
context.Database.EnsureCreated();
context.Add(new Person());
context.SaveChanges();
}
using (var context = new BloggingContext())
{
var test = context.Bases.ToList();
}
}
} |
ajcvickers
added a commit
that referenced
this issue
Dec 26, 2019
Fixes #14039 Issue was fixed as part of 3.0/3.1 changes.
ajcvickers
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Dec 26, 2019
ajcvickers
added a commit
that referenced
this issue
Dec 30, 2019
Fixes #14039 Issue was fixed as part of 3.0/3.1 changes.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
punted-for-3.0
type-bug
If you enable lazy loading, use TPH (Base, Entity1, Entity2) and have a navigational property from Entity1 to Entity2 the exception below occurs.
This is further described here
https://stackoverflow.com/questions/4811194/what-is-the-syntax-for-self-referencing-foreign-keys-in-ef-code-first
and can be reproduced here
https://github.com/Arikael/EfTest/tree/master/EfTest
as a workaround you can introduce the foreign key property yourself
Steps to reproduce
clone https://github.com/Arikael/EfTest/tree/master/EfTest
change the ConnectionString to your local DB and run the application
Further technical details
EF Core version: 2.1.4.
Database Provider: Microsoft.EntityFrameworkCore.SqlServer
Operating system: Win 10
IDE: Visual Studio 2017 15.3.9
The text was updated successfully, but these errors were encountered: