实体框架 - 使其成为只读? [英] Entity Framework - making it read only?

查看:144
本文介绍了实体框架 - 使其成为只读?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

如何使Entity Framework Data Context Readonly

是否有配置设置或简单的方法来使实体只读我有一个数据访问层与数据库是CRM解决方案的后端。我们不想在CRM界面之外写入(意外或故意)到数据库,但是我们希望通过多个自定义应用程序读取数据。

Is there a configuration setting or simple way to make Entities "read-only" I have a data access layer that goes against a db that is the back end to a CRM solution. We don't want to write (accidentaly or purposely) to the db outside of the CRM UI but we do want to read data via several custom apps.

推荐答案

对于您的自定义应用程序,连接字符串指向仅具有只读访问权限的数据库用户。如果他们尝试写入数据库,您将收到错误。

For your custom apps have the connection string point to a database user that only has read-only access. You will get errors if they then try to write to the database.

http://www.joellipman.com/articles/microsoft/sql-server/454-create- read-only-database-user-in-sql-server.html

这篇关于实体框架 - 使其成为只读?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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