简体   繁体   English

如何用密码保护使用Entity Framework Code First创建的数据库?

[英]How to password protect database that is created using Entity Framework Code First?

The title says it all: as we are nearing release of our desktop application, which uses a local database (SQLServer 2014 LocalDb), we want to password protect access to it. 标题说明了一切:随着我们即将使用本地数据库(SQLServer 2014 LocalDb)的桌面应用程序的发布,我们希望通过密码保护对它的访问。

The database will be created using EF Code First on the user's computer the first time he starts up the application. 首次启动应用程序时,将在用户的计算机上使用EF Code First创建数据库。 This must be really simple, but I seem to overlook the solutions that should present itself on Google. 这一定很简单,但是我似乎忽略了应该在Google上展示的解决方案。

The short answer here is you can't password protect LocalDb. 简短的答案是您不能用密码保护LocalDb。 LocalDb is designed to be a low friction database setup for development and testing, but it does not provide any of the advanced features of SQL or even SQL Compact Edition. LocalDb设计为低摩擦数据库设置,用于开发和测试,但是它不提供SQL甚至SQL Compact Edition的任何高级功能。 From MSDN : MSDN

LocalDB is created specifically for developers. LocalDB是专门为开发人员创建的。 It is very easy to install and requires no management 它非常容易安装,不需要管理

and then there is this: 然后是这样的:

Moreover, if the simplicity (and limitations) of LocalDB fit the needs of the target application environment, developers can continue using it in production, as LocalDB makes a pretty good embedded database too 此外,如果LocalDB的简单性(和局限性)满足目标应用程序环境的需求,则开发人员可以继续在生产环境中使用它,因为LocalDB也是一个很好的嵌入式数据库。

"pretty good" implies that while it will work, there may be better solutions. “相当好”表示虽然可以工作,但可能会有更好的解决方案。 Essentially, the lack of security is a feature of LocalDB. 本质上,缺乏安全性是LocalDB的功能。 It is designed to run as the currently logged in user, giving them full access. 它旨在以当前登录的用户身份运行,从而为他们提供完全访问权限。

If you need Database Security as a feature of your deployed application, but do not want to deal with the complexities of a full SQL installation, you should consider SQL Compact Edition. 如果您需要数据库安全性作为已部署应用程序的功能,但又不想处理完整SQL安装的复杂性,则应考虑使用SQL Compact Edition。

See this article How to: Deploy a SQL Server Compact 4.0 Database with an Application . 请参阅本文如何:使用应用程序部署SQL Server Compact 4.0数据库 Deployment will vary depending on the deployment methods used by the rest of your application. 部署将取决于应用程序其余部分使用的部署方法。

Entity Framework is an abstraction layer which is not specifically tied to a specific database technology. 实体框架是一个抽象层 ,与特定的数据库技术无关。 It will work identically with LocalDb, SQL Compact, SQL Express, MySQL, postgresql, etc... usually with nothing more than than the correct database driver and the correct connection string supplied. 它将与LocalDb,SQL Compact,SQL Express,MySQL,postgresql等完全相同,通常只需要提供正确的数据库驱动程序和正确的连接字符串即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用实体框架代码优先方法正确创建数据库 - How to correctly create a database using entity framework code first approach 如何为“实体框架代码优先”设置数据库连接? - How to set the database connection for Entity Framework Code First? 如何使用实体框架生成与SQL Server兼容的数据库(代码优先) - How to generate a SQL Server compatible database with Entity Framework (code first) 如何调试Entity Framework Code First数据库部署错误? - How to debug Entity Framework Code First database deployment error? 如何在代码优先实体框架中提供数据库配置设置? - How to provide database configuration settings in code-first Entity Framework? 我的数据库不是通过Entity Framework 6代码优先方法自动创建的吗? - My database is not getting automatically created by Entity Framework 6 code-first approach? 首先使用生产数据库部署实体框架代码 - Deploying entity framework code first with production database 实体框架6代码优先-与其他数据库的关系 - Entity Framework 6 Code First - Relations with a different DataBase 首先使用实体​​框架代码创建本地数据库 - Creating local database with Entity Framework Code First 实体框架代码优先数据库恢复模型 - Entity Framework Code First Database Recovery Model
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM