【问题标题】:Breakpoint not hit in EF Core IEntityTypeConfiguration class on add-migration in PackageManagerConsole在 PackageManagerConsole 中添加迁移时,EF Core IEntityTypeConfiguration 类中未命中断点
【发布时间】:2021-10-15 11:53:15
【问题描述】:

我正在一个小型测试项目中进行一些发现,并尝试在配置定义类中设置断点。

public class TripExpenseComparisonEntityTypeConfiguration : IEntityTypeConfiguration<TripExpenseComparison>
{
    public void Configure(EntityTypeBuilder<TripExpenseComparison> builder)
    {
        builder.HasKey(u => u.Id)
             .HasName("PK_TravelExpense");

        builder.OwnsOne(vo => vo.BudgetedTripExpense, exp =>
        {
            var x = from p in exp.GetType().GetProperties() where p.PropertyType == typeof(decimal) select p;

            exp.Property(u => u.AllowNegatives)
                .IsRequired();

            exp.Ignore(u => u.TotalExpenses);

        });
       ... rest removed

当我从包管理器控制台运行 Add-Migration 时,在 DataAccess 项目中,它运行整个迁移(正确)除了它没有命中在此行上设置的断点

>exp.Property(u => u.AllowNegatives)
        .IsRequired();

断点在这种类型的类中不起作用吗?或者他们不会在添加迁移事件中受到影响?

【问题讨论】:

    标签: c# entity-framework-core ef-fluent-api


    【解决方案1】:

    您可以在所需位置之前添加此行Debugger.Launch();。它启动并将调试器附加到进程。

    请参阅文档here

    另一个选项是使用DbMigrator 通过代码和调试运行迁移。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-10
      • 1970-01-01
      • 2017-05-30
      • 2017-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多