当我尝试从EF核心访问我的导航属性之一时出现错误:
无效的对象名称“ CoinbaseAccount”。
var userTransaction = await this.EntityDBSet.Include(x => x.IncomingCoinbaseAccount)
.FirstOrDefaultAsync(x => x.TransactionOrderId == transactionId);
该表存在于SQL中,名为dbo.CoinbaseAccounts。
modelBuilder.Entity<UserTransaction>(entity =>
{
entity.HasOne(d => d.IncomingCoinbaseAccount)
.WithMany(p => p.IncomingUserTransactions)
.HasForeignKey(d => d.IncomingCoinbaseAccountId)
.HasConstraintName("FK_UserTransactions_CoinbaseAccounts");
}
modelBuilder.Entity<CoinbaseAccount>(entity =>
{
entity.Property(e => e.AccountId)
.IsRequired()
.HasMaxLength(256);
entity.Property(e => e.Address)
.IsRequired()
.HasMaxLength(256);
}
任何想法如何解决此问题,我正在使用.Net-Core 2.1