将.net core 3.0项目更改为.net standard 2.1,并且找不到TABLE属性(对于efCore poco类)

问题描述 投票:1回答:1

我认为我应该将我的类库移动到使用.net standard 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'(是您缺少using指令或程序集引用吗?)

找不到类型或名称空间名称“表”(您是否丢失了using指令或程序集引用?)

找不到类型或名称空间名称'Schema'(您是缺少using指令或程序集引用?)

c# entity-framework-core .net-standard
1个回答
0
投票

TableAttribute属于System.ComponentModel.Annotations程序集,它是.NET Standard的TableAttribute。而且似乎没有计划包含它,请参阅is not part

您需要将其作为软件包安装

 this github issue

或使用Microsoft.EntityFrameworkCore程序包,其中包括System.ComponentModel.Annotations,如果需要更多的话

Install-Package System.ComponentModel.Annotations -Version 4.6.0
© www.soinside.com 2019 - 2024. All rights reserved.