asp.net-core - Asp Net Core - 错误持久值对象
问题描述
我正在尝试从地址中保留一个值 valueobject,但出现以下错误,我正在使用 postgres,并且我已经尝试以多种方式映射此类,我看到有些人有类似的问题,但我没有找到解决方案。我只在使用 ef core 时遇到这个错误
System.InvalidOperationException:''EmpresaModel' 类型的实体正在与'EnderecoEmpresa' 类型的实体共享表'Empresa.Empresa',但没有具有相同键值的此类型实体已标记为'已添加' . 考虑使用“DbContextOptionsBuilder.EnableSensitiveDataLogging”来查看键值。
builder.OwnsOne(e => e.EnderecoEmpresa, a =>
{
a.Property(p => p.Bairro).HasMaxLength(50)
.HasColumnName("Bairro")
.HasDefaultValue("");
a.Property(p => p.CEP).HasMaxLength(10)
.HasColumnName("CEP")
.HasDefaultValue("");
a.Property(p => p.Complemento).HasMaxLength(60)
.HasColumnName("Complemento")
.HasDefaultValue("");
a.Property(p => p.IdMunicipio)
.HasColumnName("MunicipioId");
a.Property(p => p.IdUF)
.HasColumnName("UfId");
a.Property(p => p.Logradouro)
.HasColumnName("Logradouro").HasMaxLength(60)
.HasDefaultValue("");
a.Property(p => p.Numero)
.HasColumnName("Numero").HasMaxLength(10)
.HasDefaultValue("");
});
解决方案
推荐阅读
- mysql - 在 mac 上安装 asp.net mvc web 应用程序,但出现这些错误
- excel - 将公共变量转移到其他工作表的问题
- python - Fail to upload multiple objects with boto3 to google storage
- django - /play/api/5/play/ 处的 Django AssertionError `request` 参数必须是 `django.http.HttpRequest` 的实例,而不是 `myApp.views.TrackPlayAPIToggle`
- php - Netbeans:如何上传更改的文件?
- c# - UWP VisualTreeHelper 参数错误参考
- javascript - 如何防止div下滑?
- powershell - 无法使用 ParseExact() 解析日期
- java - 设计库存管理中的转移模式
- jenkins-pipeline - 如何从 Pipeline Jenkins 中减少一天?