c# - HasNoDiscriminator 在 EFCore 中的使用

标签 c# entity-framework-core

我正在开发 EntityFrameworkCore.Cosmo 提供程序并遇到 HasNoDiscriminator 方法。
保留下面的代码有什么用?

 modelBuilder.Entity<Patient>().HasNoDiscriminator();

最佳答案

这是特定于 Cosmos 的模型定制。

To identify the entity type that a given item represent EF Core adds a discriminator value even if there are no derived entity types. The name and value of the discriminator can be changed.

If no other entity type will ever be stored in the same container the discriminator can be removed by calling HasNoDiscriminator.

来源:Cosmos-specific model customization

我怀疑目标是防止患者以外的其他实体存储在容器中。

关于c# - HasNoDiscriminator 在 EFCore 中的使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59712278/

相关文章:

c# - 以委托(delegate)为值的字典

c# - 如何在 MassTransit 和 Automatonymous 中配置 EF Core 持久性?

c# - 通过 msi 文件在 Windows Mobile 中部署 .Net Compact Framework 应用程序

c# - 如何向我的表单动态添加按钮?

C# connection.Open() 异常

c# - EF 7(Beta 7)一对一关系

c# - MySql.Data.MySqlClient.MySqlException : Duplicate entry

c# - File.AppendAllText 中的 FileNotFoundException

c# - 如何获取列条目之一相同的行数

c# - 无法使用 MemoryCache 访问已处理的对象