实体框架6 DBContext禁用删除选项 [英] Entity Framework 6 DBContext disable delete option

查看:287
本文介绍了实体框架6 DBContext禁用删除选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人请帮助我如何禁用EF6中的DELETE选项?



我的意思是从应用程序,现在的记录应该被删除(甚至意外)



谢谢。

解决方案

在数据库中创建一个没有删除/修改记录的权限,并在应用程序中使用它。 EF本身不是一个安全工具,并且总是有执行删除操作的选项(例如,开发人员可以将任意的SQL查询/命令发送到数据库,绕过数据访问层中实现的所有安全措施) / p>

Anyone please help me on how to disable DELETE option in EF6?

I mean from the application, now record should be deleted (even accidentally)

Thanks.

解决方案

Create a user/role in the database that does not have permissions to delete/modify records and use it in your application. EF itself is not meant to be a security tool and there are always options to perform a delete operation (e.g. a developer can send any arbitrary SQL query/command to the database bypassing all the 'security' measures implemented in the data access layer)

这篇关于实体框架6 DBContext禁用删除选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆