我的实体是从 Entity 类派生的,所以默认情况下它应该有一个 int 类型的 id,但由于某种原因 EntityFramework 无法识别它。我什至尝试手动设置我的主键(已注释掉),但它仍然无法正常工作。
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Text;
using Abp.Domain.Entities;
using Abp.Domain.Entities.Auditing;
using Abp.Timing;
namespace Test.Models
{
[Table("AppTasks")]
public class Task : Entity, IHasCreationTime
{
//[Key]
//public int Id { get; set; }
public const int MaxTitleLength = 256;
public const int MaxDescriptionLength = 64 * 1024;
[Required]
[StringLength(MaxTitleLength)]
public string Title { get; set; }
[StringLength(MaxDescriptionLength)]
public string Description { get; set; }
public TaskState State { get; set; }
public DateTime CreationTime { get; set; }
public Task()
{
CreationTime = Clock.Now;
State = TaskState.Open;
}
public Task(string title, string description = null) : this()
{
Title = title;
Description = description;
}
}
public enum TaskState : byte
{
Open = 0,
Completed = 1
}
}