This commit is contained in:
sunkaixuan 2022-08-11 19:10:32 +08:00
parent 585bd372d5
commit cd3a2eb097
2 changed files with 9 additions and 1 deletions

View File

@ -19,14 +19,21 @@ namespace OrmTest
InitKeyType = InitKeyType.Attribute,
IsAutoCloseConnection = true
});
db.DbMaintenance.CreateDatabase();
//db.DbMaintenance.CreateDatabase();
db.CodeFirst.InitTables(typeof(CodeFirstTable1));//Create CodeFirstTable1
db.Insertable(new CodeFirstTable1() { Name = "a", Text="a" }).ExecuteCommand();
var list = db.Queryable<CodeFirstTable1>().ToList();
db.CodeFirst.InitTables<DateTimeTest2>();
db.Insertable(new DateTimeTest2() { }).ExecuteCommand();
Console.WriteLine("#### CodeFirst end ####");
}
}
public class DateTimeTest2
{
[SugarColumn(IsNullable =true)]
public DateTime? dt { get; set; }
}
public class CodeFirstTable1
{
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]

View File

@ -11,6 +11,7 @@ namespace OrmTest
/// <param name="args"></param>
static void Main(string[] args)
{
DemoE_CodeFirst.Init();
Demo0_SqlSugarClient.Init();
Demo1_Queryable.Init();
Demo2_Updateable.Init();