-
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
Multiple properties with default implementation in an interface, applied to an abstract hierarchy, causes scaffolding to fail #23261
Comments
I also tried removing only the |
Error is not related to EF Core at all. It happens without EF Core too. using System;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Reflection;
namespace BugInReflection
{
class Program
{
static void Main(string[] args)
{
var p = typeof(Program).GetProperties().Select(e => e.GetIndexParameters()).ToList();
}
public BlogPost BlogPost { get; set; }
}
public interface ITitle
{
// commenting out one or more of these NotMapped properties fixes the problem
[NotMapped] public string Temp1 => "abcd";
[NotMapped] public string Temp2 => "abcd";
[NotMapped] public string Temp3 => "abcd";
[NotMapped] public string Temp4 => "abcd";
[NotMapped] public string Temp5 => "abcd";
public string Title { get; set; } // commenting out this property also fixes the problem
}
public abstract class Post : ITitle // making this non-abstract also fixes the problem
{
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public string Title { get; set; }
}
public class BlogPost : Post { }
} |
Thank you for the quick response and debugging to figure out that the bug is external to EF Core. I should have dug deeper myself. I have now filed a bug in the appropriate repo dotnet/runtime#44533. |
Consider an interface which uses the default implementation feature on some temporary variables. Those temporary variables are marked with the
[NotMapped]
attribute. If too many of those variables are used, and the interface is applied to an inheritance hierarchy which contains an abstract ancestor, then the model is unable to scaffold. Please see the code example below:EF Core version: 5.0 RTM
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET 5.0 RTM
Operating system: Windows 10 Pro 20H2
IDE: Visual Studio 2019 16.8.0
The text was updated successfully, but these errors were encountered: