简体   繁体   中英

How to use The MetadataType Attribute in a library targeting .net standard 1.4

I created a library targeting the .net standard 1.4. The library contains my domain model (POCOs). I want to decorate my classes with the MetadataType and the dataannotations attributes. I installed the System.ComponentModel.Annotations but the MetaDataTypeAttribute is absent. I tried to install the Microsoft.Aspnet.Mvc package but is not compatible with .net standard 1.4. Can any body tell me, how can i do to inherit the dataAnnotations defined in my interfaces in a library targeting .net standard 1.4 ? Thanks.

MetadataTypeAttribute - along with BindableTypeAttribute and ScaffoldTableAttribute - is not part of any version of .NET Standard (<= 2.0) and also not available on .NET Core so you cannot currently use it in a .NET Standard project and you cannot load a .NET Framework library into .NET Core 2.0 that uses it.

See this and this GitHub issues for details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM