mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-04-24 18:04:52 +08:00
Update CodeFirst
This commit is contained in:
parent
23d92b7cdf
commit
8b99025d0d
@ -79,6 +79,7 @@
|
||||
<Compile Include="Models\ViewOrder.cs" />
|
||||
<Compile Include="UnitTest\UQueue.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug2.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug5.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug4.cs" />
|
||||
<Compile Include="_OldTest\BugTest\BugModels\AccountsModel.cs" />
|
||||
<Compile Include="_OldTest\BugTest\BugModels\ClientsModel.cs" />
|
||||
@ -93,7 +94,7 @@
|
||||
<Compile Include="_OldTest\BugTest\BugModels\TStock.cs" />
|
||||
<Compile Include="_OldTest\BugTest\BugModels\TTempStock.cs" />
|
||||
<Compile Include="_OldTest\BugTest\BugModels\VMaterialInfo.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug3t.cs" />
|
||||
<Compile Include="_OldTest\BugTest\Bug3.cs" />
|
||||
<Compile Include="_OldTest\Demos\H_Queue.cs" />
|
||||
<Compile Include="_OldTest\Demos\I_InsertOrUpdate.cs" />
|
||||
<Compile Include="_OldTest\Demos\J_Debugger.cs" />
|
||||
|
128
Src/Asp.Net/SqlServerTest/_OldTest/BugTest/Bug5.cs
Normal file
128
Src/Asp.Net/SqlServerTest/_OldTest/BugTest/Bug5.cs
Normal file
@ -0,0 +1,128 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest.Test
|
||||
{
|
||||
public class BugTest5
|
||||
{
|
||||
public static void Init()
|
||||
{
|
||||
SqlSugarClient Db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = Config.ConnectionString,
|
||||
DbType = DbType.SqlServer,
|
||||
IsAutoCloseConnection = true,
|
||||
//MoreSettings = new ConnMoreSettings()
|
||||
//{
|
||||
// PgSqlIsAutoToLower = true //我们这里需要设置为false
|
||||
//},
|
||||
InitKeyType = InitKeyType.Attribute,
|
||||
});
|
||||
//调式代码 用来打印SQL
|
||||
Db.Aop.OnLogExecuting = (sql, pars) =>
|
||||
{
|
||||
Console.WriteLine(sql);
|
||||
};
|
||||
|
||||
Db.CodeFirst.InitTables(typeof(Base_MenuList));
|
||||
Db.CodeFirst.InitTables(typeof(aaaa));
|
||||
Db.CodeFirst.InitTables(typeof(bbbbb));
|
||||
|
||||
}
|
||||
[SugarTable("xxxx.Base_MenuList")]
|
||||
|
||||
public class Base_MenuList
|
||||
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 菜单主键Id
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "菜单主键Id")]
|
||||
|
||||
public int MenuID { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 名称
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "名称")]
|
||||
|
||||
public string MenuName { get; set; }
|
||||
|
||||
}
|
||||
|
||||
[SugarTable("xxxx1x")]
|
||||
|
||||
public class aaaa
|
||||
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 菜单主键Id
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "菜单主键Id")]
|
||||
|
||||
public int MenuID { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 名称
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "名称")]
|
||||
|
||||
public string MenuName { get; set; }
|
||||
|
||||
}
|
||||
[SugarTable("bbbbb")]
|
||||
|
||||
public class bbbbb
|
||||
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 菜单主键Id
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnDescription = "菜单主键Id")]
|
||||
|
||||
public int MenuID { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
|
||||
/// 名称
|
||||
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "名称")]
|
||||
|
||||
public string MenuName { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -109,6 +109,9 @@ namespace SqlSugar
|
||||
}
|
||||
}
|
||||
var tableName = GetTableName(entityInfo);
|
||||
this.Context.MappingTables.Add(entityInfo.EntityName,tableName);
|
||||
entityInfo.DbTableName = tableName;
|
||||
entityInfo.Columns.ForEach(it => { it.DbTableName = tableName; });
|
||||
var isAny = this.Context.DbMaintenance.IsAnyTable(tableName);
|
||||
if (isAny)
|
||||
ExistLogic(entityInfo);
|
||||
|
Loading…
Reference in New Issue
Block a user