首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在EFCore3.1中映射ValueObject

如何在EFCore3.1中映射ValueObject
EN

Stack Overflow用户
提问于 2020-03-19 16:26:05
回答 1查看 111关注 0票数 0

实体:

代码语言:javascript
复制
public class Good : FullAuditedAggregateRoot<Guid>
{
   ///******///
  public virtual SaleStates SaleStates { get; set; }
}

ModelBuilder:

代码语言:javascript
复制
builder.Entity<Good>(b =>
{
  ///******///
  b.OwnsOne(f=>f.SaleStates).WithOwner();
}

错误:

代码语言:javascript
复制
System.InvalidOperationException : The type 'SaleStates' cannot be marked as owned because a non-owned entity type with the same name already exists.

https://docs.microsoft.com/en-us/ef/core/what-is-new/ef-core-3.0/breaking-changes#config

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-07-19 20:56:47

这似乎是总部基地的一个问题。遇到这个问题时,唯一对我有帮助的就是在值对象的类名上使用[Owned]属性。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60753365

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档