CodeFirst support not null default

This commit is contained in:
sunkaixuan
2022-04-23 15:25:10 +08:00
parent 4186e0820e
commit 5bdf1ca4a7
2 changed files with 43 additions and 1 deletions

View File

@@ -15,8 +15,31 @@ namespace OrmTest
Db.DbMaintenance.DropTable("UnitCodeTest1");
Db.CodeFirst.InitTables<UnitCodeTest1>();
Db.CodeFirst.InitTables<UnitCodeFirstpks2>();
if (Db.DbMaintenance.IsAnyTable("UnitCodeFirst131", false))
Db.DbMaintenance.DropTable("UnitCodeFirst131");
Db.CodeFirst.InitTables<UnitCodeFirst131>();
Db.Insertable(new UnitCodeFirst131() { Id = 1 }).ExecuteCommand();
Db.CodeFirst.InitTables<UNITCODEFIRST131>();
Db.CodeFirst.InitTables<UNITCOdEFIRST131>();
}
public class UnitCodeFirst131
{
public int Id { get; set; }
}
public class UNITCODEFIRST131
{
public int Id { get; set; }
[SqlSugar.SugarColumn(DefaultValue ="a")]
public string Name { get; set; }
}
public class UNITCOdEFIRST131
{
public int Id { get; set; }
[SqlSugar.SugarColumn(DefaultValue = "a")]
public string Name { get; set; }
[SqlSugar.SugarColumn(DefaultValue = "getdate()")]
public DateTime dt { get; set; }
}
public class UnitCodeFirstpks2
{
[SqlSugar.SugarColumn(IsPrimaryKey =true)]