mirror of
https://gitee.com/dotnetchina/SqlSugar.git
synced 2025-09-19 01:58:13 +08:00
CodeFirst adds database index and default value
This commit is contained in:
@@ -116,6 +116,7 @@
|
||||
<Compile Include="OldTests\UnitTest\Update.cs" />
|
||||
<Compile Include="UnitTest\Main.cs" />
|
||||
<Compile Include="UnitTest\UAdo.cs" />
|
||||
<Compile Include="UnitTest\UCodeFirst.cs" />
|
||||
<Compile Include="UnitTest\UJson.cs" />
|
||||
<Compile Include="UnitTest\Updateable.cs" />
|
||||
<Compile Include="UnitTest\UQueryable.cs" />
|
||||
|
@@ -25,6 +25,7 @@ namespace OrmTest
|
||||
});
|
||||
public static void Init()
|
||||
{
|
||||
CodeFirst();
|
||||
Updateable();
|
||||
Json();
|
||||
Ado();
|
||||
|
26
Src/Asp.Net/MySqlTest/UnitTest/UCodeFirst.cs
Normal file
26
Src/Asp.Net/MySqlTest/UnitTest/UCodeFirst.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace OrmTest
|
||||
{
|
||||
public partial class NewUnitTest
|
||||
{
|
||||
public static void CodeFirst()
|
||||
{
|
||||
if (Db.DbMaintenance.IsAnyTable("UnitCodeTest1", false))
|
||||
Db.DbMaintenance.DropTable("UnitCodeTest1");
|
||||
Db.CodeFirst.InitTables<UnitCodeTest1>();
|
||||
Db.CodeFirst.InitTables<UnitCodeTest1>();
|
||||
}
|
||||
public class UnitCodeTest1
|
||||
{
|
||||
[SqlSugar.SugarColumn(IndexGroupNameList = new string[] { "group1" })]
|
||||
public int Id { get; set; }
|
||||
[SqlSugar.SugarColumn(DefaultValue = "now()", IndexGroupNameList = new string[] { "group1" })]
|
||||
public DateTime? CreateDate { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user