实体框架 - [Keyless] 数据注释缺失 [英] Entity Framework - [Keyless] Data Annotation Missing

查看:34
本文介绍了实体框架 - [Keyless] 数据注释缺失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 Microsoft 文档 在这里,我应该可以访问 [Keyless] 的属性,这样我就可以定义我的模型具有无键,这样在我的 DBContext 中我可以有类似的东西:

According with the Microsoft Documentation Here, I should have access to the Attribute for [Keyless] so I can define my Model has Keyless, so that in my DBContext I could have something like:

public DbSet<MyKeylessClass> KeylessModel { get; set; }

并使用 _context.KeylessModel.FromSqlRaw(...),而无需向其添加 PK.我有对 System.ComponentModel.DataAnnotations 的引用,并且除了 Keyless 之外的所有属性都在那里,我在这里缺少什么?

And use _context.KeylessModel.FromSqlRaw(...), without having the need to add a PK to it. I have the reference to System.ComponentModel.DataAnnotations and all the Attributes except Keyless are there, what am I missing here?

推荐答案

您可能错过了链接文档主题开头的注意的以下部分

You've probably missed the following part of the Note at the very beginning of the linked documentation topic

[Keyless] 数据注释在 EFCore 5.0 中可用.

The [Keyless] Data Annotation became available in EFCore 5.0.

成为"?在 EFCore 5.0 中"?拜托,目前还没有EFCore 5.0.

"became"? "in EFCore 5.0"? Come on, there is no EFCore 5.0 at this time.

无论如何,看起来他们正在主动记录未来的事情,所以当某些东西丢失或与记录的不同时,请注意这一点.

Anyway, looks like they are proactively documenting future things, so just be aware of that when something is missing or is different than the documented.

这篇关于实体框架 - [Keyless] 数据注释缺失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆