I Have read more similar questions as this...
我读过更多类似的问题......
I have created a BD but after to creation I thought to add a DateTime
field to save the datetime registration, but when I type update-database (after creation the migration), the Package Manager Console show me the error of the title
我创建了一个BD但是在创建之后我想添加一个DateTime字段来保存日期时间注册,但是当我输入update-database(创建迁移后)时,包管理器控制台会显示标题的错误
I already tried this:
我已经尝试过了:
AlterColumn("dbo.Dispositivoes", "RegisterDate", c => c.DateTime(nullable: false, defaultValueSql: "GETDATE()"));
AlterColumn("dbo.Dispositivoes", "RegisterDate", c => c.DateTime(nullable: false, defaultValue: DateTime.Now));
new DataColumn("myDate", typeof(DateTime));
This show ever the same error. I do not have idea to resolve this, any help me please?
这显示出同样的错误。我无意解决这个问题,请帮助我吗?
Thanks!!
1 个解决方案
#1
0
have you tried
你有没有尝试过
Sql("alter table dbo.Dispositivoes alter column RegisterDate datetime2 not null default getdate()")
or
AlterColumn("dbo.Dispositivoes", "RegisterDate", c => c.DateTime(nullable: false, storeType: "datetime2", defaultValueSql: "GETDATE()"));
#1
0
have you tried
你有没有尝试过
Sql("alter table dbo.Dispositivoes alter column RegisterDate datetime2 not null default getdate()")
or
AlterColumn("dbo.Dispositivoes", "RegisterDate", c => c.DateTime(nullable: false, storeType: "datetime2", defaultValueSql: "GETDATE()"));