-
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
dotnet ef migrations add freezes #29826
Labels
area-model-building
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
Servicing-approved
type-bug
Milestone
Comments
@AndriySvyryd Hangs in model building; minimal repro below. Regression from 6.0. Still fails on latest main. public class Bond : Investment
{
public virtual ICollection<Coupon> Coupons { get; set; }
}
public class Coupon : InvestmentYield
{
}
public class Dividend : InvestmentYield
{
}
public abstract class Investment
{
public int Id { get; set; }
}
public abstract class InvestmentYield
{
public int Id { get; set; }
public Investment Investment { get; set; }
public int InvestmentId { get; set; }
}
public class Stock : Investment
{
public virtual ICollection<Dividend> Dividends { get; set; }
}
public class SomeDbContext : DbContext
{
public DbSet<Investment> Investments { get; set; }
public DbSet<Stock> Stocks { get; set; }
public DbSet<Bond> Bonds { get; set; }
public DbSet<InvestmentYield> Yields { get; set; }
public DbSet<Dividend> Dividends { get; set; }
public DbSet<Coupon> Coupons { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
=> optionsBuilder
.UseSqlServer(@"Data Source=(LocalDb)\MSSQLLocalDB;Database=AllTogetherNow")
.LogTo(Console.WriteLine, LogLevel.Information)
.EnableSensitiveDataLogging();
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Dividend>().HasOne<Stock>()
.WithMany(s => s.Dividends)
.HasForeignKey(e => e.InvestmentId);
// Model building hangs on this line:
modelBuilder.Entity<Coupon>().HasOne<Bond>()
.WithMany(b => b.Coupons)
.HasForeignKey(e => e.InvestmentId);
}
}
public class Program
{
public static async Task Main()
{
using (var context = new SomeDbContext())
{
Console.WriteLine("Building model...");
var model = context.Model;
Console.WriteLine("Model built.");
}
}
} |
AndriySvyryd
added a commit
that referenced
this issue
Dec 14, 2022
AndriySvyryd
added
the
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
label
Dec 14, 2022
AndriySvyryd
added a commit
that referenced
this issue
Dec 14, 2022
AndriySvyryd
added a commit
that referenced
this issue
Dec 15, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area-model-building
closed-fixed
The issue has been fixed and is/will be included in the release indicated by the issue milestone.
customer-reported
Servicing-approved
type-bug
Hello,
I have problems with migrations freezing. I tried using Local SQL Server and SQLite database, it was freezing with both, so it seems provider independent.
Here is very shortened part of my entities and mapping:
And now mapping:
Here is repo with sample project for reproduction:
https://github.com/klinki/ef-core-issue
Include verbose output
Here is verbose output from
dotnet ef migrations add MappingMigration
. There is not much to see there, it freezes basically right away.Include provider and version information
EF Core version: 7.0.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer (same happens also for Microsoft.EntityFrameworkCore.Sqlite, maybe it is provider independent issue)
Target framework: .NET 7
Operating system: Windows 10
IDE: Visual Studio 2022 17.4
The text was updated successfully, but these errors were encountered: