From b01c0488b42d57168bdd9e69d336cfd12b6d9ded Mon Sep 17 00:00:00 2001 From: sunkaixuan <610262374@qq.com> Date: Fri, 15 Apr 2022 20:14:26 +0800 Subject: [PATCH] update sqlite --- .../Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs | 5 ++++- Src/Asp.NetCore2/SqliteTest/UnitTest/UCodeFirst.cs | 9 ++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Src/Asp.NetCore2/SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs b/Src/Asp.NetCore2/SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs index c4cd68c62..f330c44fd 100644 --- a/Src/Asp.NetCore2/SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs +++ b/Src/Asp.NetCore2/SqlSugar/Realization/Sqlite/CodeFirst/SqliteCodeFirst.cs @@ -11,7 +11,10 @@ namespace SqlSugar { if (entityInfo.Columns.HasValue()&&entityInfo.IsDisabledUpdateAll==false) { - Check.Exception(entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1, "Use Code First ,The primary key must not exceed 1"); + if (entityInfo.Columns.Where(it => it.IsPrimarykey).Count() > 1) + { + return; + } var tableName = GetTableName(entityInfo); var dbColumns = this.Context.DbMaintenance.GetColumnInfosByTableName(tableName,false); diff --git a/Src/Asp.NetCore2/SqliteTest/UnitTest/UCodeFirst.cs b/Src/Asp.NetCore2/SqliteTest/UnitTest/UCodeFirst.cs index 80aebe7a7..452a459f7 100644 --- a/Src/Asp.NetCore2/SqliteTest/UnitTest/UCodeFirst.cs +++ b/Src/Asp.NetCore2/SqliteTest/UnitTest/UCodeFirst.cs @@ -17,8 +17,15 @@ namespace OrmTest Db.DbMaintenance.TruncateTable(); Db.Insertable(new Test00111()).ExecuteCommand(); var list = Db.Queryable().ToList(); + Db.CodeFirst.InitTables(); + } + public class Test00111121 + { + [SugarColumn(IsPrimaryKey = true)] + public string id { get; set; } + [SugarColumn(IsPrimaryKey =true)] + public string creater { get; set; } } - public class Test00111 { public int id { get; set; }