Code First ef SQL Server 版本不支持数据类型“datetime2”
When calling DbContext.SaveChanges
, I get a DbUpdateException:
An unhandled exception of type 'System.Data.Entity.Infrastructure.DbUpdateException' occurred in EntityFramework.dll. Additional information: An error occurred while updating the entries. See the inner exception for details.
解决:
modelBuilder.Entity<Blog>().Property(t => t.CreatedOn).HasColumnName("CreatedOn").HasColumnType("date");
参考:
https://social.msdn.microsoft.com/Forums/en-US/16f364d6-2acd-4106-9060-de666f499d57/how-to-set-the-providermanifesttoken-with-ef-code-first?forum=adodotnetentityframework
-----------------------------------
http://www.cnblogs.com/rock_chen/