C# 将目标从netcoreapp3.0更改为netstandard2.1时缺少TableAttribute
我想我应该把类库改为使用.net标准2.1 表属性不在.net标准2.1中吗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
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