![](/img/trans.png)
[英]EF Core migration error: PositionalParameterNotFound,Add-Migration
[英]Breakpoint not hit in EF Core IEntityTypeConfiguration class on add-migration in PackageManagerConsole
我正在一个小型测试项目中做一些发现,并试图在配置定义 class 中命中断点。
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
当我从 package 管理器控制台运行 Add-Migration 时,在 DataAccess 项目中,它运行整个迁移(正确),除了它没有命中此行上设置的断点
>exp.Property(u => u.AllowNegatives)
.IsRequired();
断点不是class这种类型的function吗? 或者他们在添加迁移事件中不会受到打击?
如果你有Database.Migrate();
调用你的Startup.cs
然后断点应该被击中。
如果您这样做但仍然没有,请确保您在 DbContext class 中应用配置。
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.ApplyConfigurationsFromAssembly(Assembly.GetAssembly(typeof(MyDbContext)));
}
其中MyDbContext
是此 class 或 class 在与您的IEntityTypeConfiguration<T>
配置相同的程序集中的名称。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.