我想我应该将类库移动到使用.net标准2.1。
表属性不是.net标准的2.1吗?
using PWDRS.Core.Entities.Base;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace PWDRS.Core.Entities
{
[Table("ReportType", Schema = "RF")]
public class RfReportType : EntityBase
{
public RfReportType()
{
}命名空间'DataAnnotations‘中不存在类型或名称空间名称'System.ComponentModel’(是否缺少程序集引用?) 无法找到类型或命名空间名称'TableAttribute‘(您是缺少使用指令还是程序集引用?) 无法找到类型或命名空间名称“表”(您是缺少了使用指令还是程序集引用?) 无法找到类型或命名空间名称'Schema‘(您是缺少了使用指令还是程序集引用?)
发布于 2019-11-19 22:59:00
TableAttribute属于System.ComponentModel.Annotations程序集,.NET标准的不是一部分。而且似乎没有包含它的计划,请参阅这个github问题
您需要将它作为一个软件包安装。
Install-Package System.ComponentModel.Annotations -Version 4.6.0或者使用包含Microsoft.EntityFrameworkCore包的System.ComponentModel.Annotations,如果需要更多
Install-Package Microsoft.EntityFrameworkCore -Version 3.0.1https://stackoverflow.com/questions/58943845
复制相似问题