实体框架-[无键]数据注释丢失 [英] Entity Framework - [Keyless] Data Annotation Missing
问题描述
根据Microsoft文档在这里,我应该可以访问[Keyless]的属性,以便可以将Model定义为具有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
[无键]
数据注释在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.
这篇关于实体框架-[无键]数据注释丢失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!