Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/331.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将目标从netcoreapp3.0更改为netstandard2.1时缺少TableAttribute_C#_.net Core_Entity Framework Core_.net Standard - Fatal编程技术网

C# 将目标从netcoreapp3.0更改为netstandard2.1时缺少TableAttribute

C# 将目标从netcoreapp3.0更改为netstandard2.1时缺少TableAttribute,c#,.net-core,entity-framework-core,.net-standard,C#,.net Core,Entity Framework Core,.net Standard,我想我应该把类库改为使用.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("Rep

我想我应该把类库改为使用.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”(是 是否缺少using指令或程序集引用?)

找不到类型或命名空间名称“Table”(是否缺少) 使用指令或组件引用?)

找不到类型或命名空间名称“Schema”(是否为“”) 缺少使用指令或程序集引用?)

属于.NET标准的System.ComponentModel.Annotations程序集。而且似乎没有计划将其包括在内,明白吗

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

Install-Package System.ComponentModel.Annotations -Version 4.6.0
如果需要更多,请使用包含System.ComponentModel.Annotations的Microsoft.EntityFrameworkCore包

Install-Package Microsoft.EntityFrameworkCore -Version 3.0.1

这是在核心项目,这是数据库不可知的,我想第一个选择是最好的。。或者我可以在上下文中定义实体细节?试图找出哪一个最有意义取决于…,我建议使用第一个,但如果您在CORE项目中需要与EntityFrameworkCore相关的其他内容,那么两个包都使用是没有意义的,请仅使用Microsoft.EntityFrameworkCore