为主键增加KeyAttribute特性

This commit is contained in:
Falcon 2024-12-03 17:36:56 +08:00
parent d3679de856
commit b079a7d390
3 changed files with 5 additions and 0 deletions

View File

@ -1,5 +1,6 @@
using SqlSugar; using SqlSugar;
using System; using System;
using System.ComponentModel.DataAnnotations;
namespace Falcon.SugarApi.DatabaseDefinitions namespace Falcon.SugarApi.DatabaseDefinitions
{ {
@ -10,6 +11,7 @@ namespace Falcon.SugarApi.DatabaseDefinitions
/// <summary> /// <summary>
/// 主键 /// 主键
/// </summary> /// </summary>
[Key]
[SugarColumn(IsPrimaryKey = true,ColumnDescription = "主键")] [SugarColumn(IsPrimaryKey = true,ColumnDescription = "主键")]
public Guid? Id { get; set; } = Guid.NewGuid(); public Guid? Id { get; set; } = Guid.NewGuid();
} }

View File

@ -1,4 +1,5 @@
using SqlSugar; using SqlSugar;
using System.ComponentModel.DataAnnotations;
namespace Falcon.SugarApi.DatabaseDefinitions namespace Falcon.SugarApi.DatabaseDefinitions
{ {
@ -10,6 +11,7 @@ namespace Falcon.SugarApi.DatabaseDefinitions
/// <summary> /// <summary>
/// 主键 默认GUID 382c74c3-721d-4f34-80e5-57657b6cbc27 /// 主键 默认GUID 382c74c3-721d-4f34-80e5-57657b6cbc27
/// </summary> /// </summary>
[Key]
[SugarColumn(IsPrimaryKey = true,ColumnDescription = "主键")] [SugarColumn(IsPrimaryKey = true,ColumnDescription = "主键")]
public int? Id { get; set; } public int? Id { get; set; }
} }

View File

@ -12,6 +12,7 @@ namespace Falcon.SugarApi.DatabaseDefinitions
/// 主键 默认GUID 382c74c3-721d-4f34-80e5-57657b6cbc27 /// 主键 默认GUID 382c74c3-721d-4f34-80e5-57657b6cbc27
/// </summary> /// </summary>
[SugarColumn(IsPrimaryKey = true,ColumnDescription = "主键")] [SugarColumn(IsPrimaryKey = true,ColumnDescription = "主键")]
[Key]
[MaxLength(36)] [MaxLength(36)]
public string? Id { get; set; } public string? Id { get; set; }
} }