且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用数据库拦截器的实体框架软删除实现不起作用

更新时间:2022-11-05 07:38:04

ApplicationDbContext.cs中存在错误:

There is a bug in ApplicationDbContext.cs:

protected new void OnModelCreating(DbModelBuilder modelBuilder) {...}

您使用的是"new"而不是"override",因此永远不会执行OnModelCreating(尝试添加断点进行检查).因此AttributeToTableAnnotationConvention永远不会运行,也永远不会添加实体注释.

You are using "new" instead of "override" so OnModelCreating is never executed (try to add a breakpoint to check it). So AttributeToTableAnnotationConvention never runs and entity annotation is never added.

更改为

protected override void OnModelCreating(DbModelBuilder modelBuilder) {...}

将使其正常工作