我有一个带有触发器的视图instead of,我尝试将其与 EF Core 一起使用,EF Core 尝试以merge语句的形式将批量插入一起。这是我的表格和视图:
create table tbl (id uniqueidentifier not null primary key, data nvarchar(max) null)
go
create view vwTbl as select * from tbl
go
create trigger vwTblInsert on vwTbl instead of insert as
insert into tbl (id, data)
select id, data
from inserted
go
Run Code Online (Sandbox Code Playgroud)
以下是 EF 生成的近似 SQL:
declare @inserted1 table ([id] uniqueidentifier);
merge vwTbl using (
values (newid(), 'xxx')
) as i (id, data) on 1=0
when not matched then …Run Code Online (Sandbox Code Playgroud)