前言
这篇不会细谈功能, 只是一个总链接.
参考
Docs – What's New in EF Core 7.0
Breaking Change
参考: Docs – Breaking changes in EF Core 7.0 (EF7)
Encrypt defaults to true for SQL Server connections
我 follow EF Core – 搭建单侧环境 做了一遍, 在运行 dotnet ef database update 后就出现了 error
A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)
其原因是 EF7 依赖了 Microsoft.Data.SqlClient 5.0.0
Github Issue – EFCore.SqlServer 6.0.1 Untrusted certificate authority error
而 Microsoft.Data.SqlClient 4.0.0 的时候有一个 breaking change
解决方法有好几个
最简单的是在 ConnectionStrings 加上 TrustServerCertificate=True, 变成这样
Server=192.168.1.152;Database=EFCore7;Trusted_Connection=True;MultipleActiveResultSets=true;TrustServerCertificate=True
这个 for development 情况下是可以的, 在 production 的时候就不太理想了. 但我目前还没有 EF Core 7.0 production 的项目, 之后才研究 TODO...
SQL Server tables with triggers now require special EF Core configuration
EF7 对 multiple insert 在 SaveChanges 时做了一些优化 (快 4 倍), 但是在 SQL Server + Trigger (after insert) 的情况下, 这个优化跑不了.
所以当 Table 有使用 Trigger 就必须通知 EF Core 这样它就会 fallback 用回以前的 query.
modelBuilder .Entity<BlogWithTrigger>() .ToTable(tb => tb.HasTrigger("TRG_InsertUpdateBlog"));
Trigger 名字不重要, 因为只是要表达 "有" 而已. 如果想直接把所有 tables 都设置成 trigger 可以用这个 Model Convention.
JSON Columns
ExecuteUpdate and ExecuteDelete (Bulk updates)
看这篇 EF Core – ExecuteUpdate and ExecuteDelete (Bulk updates 批量更新和删除)