A具有一个称为Service的实体。该实体有一个称为TypeService的子实体。 在数据库(MySQL)中,TypeService可以为null。
public class Service
{
public int Id { get; set; }
public string Name{ get; set; }
public string Department { get; set; }
public TypeService TypeService { get; set; }
}
MySQL:
`TypeServiceId` bigint(20) default NULL //(Colunm of Service table)
当我尝试创建不带TypeService的服务(TypeService == null)时,它工作正常。 当我尝试编辑服务并包含TypeService时,它工作正常。 当我尝试编辑服务并更改TypeService时,效果很好。
我的问题是:当我尝试更新服务并将TypeService设置为null时,EF不会更新此TypeServiceId
为什么要进行ef核心更新以将TypeServiceId fild正确更改为另一个值,但不要更改为null值?
没有错误消息。
感谢和问候!
答案 0 :(得分:1)
据我了解,您想将TypeServiceId设置为null而不关心该实体是否仍存在于任何表中? 在这种情况下,您可以添加属性
const redView = () => {
return
<View
style={styles.redStyle}
onLayout={({nativeEvent}) =>
console.log(nativeEvent.layout.height)
}
/>
}
只需将TypeServiceId更改为null,而不是实体本身即可。确保检查迁移中的更改,以使EntityFramework不会创建新列,而不会使用创建的列。