[英].NET Membership in ASP.NET MVC4 and Entity Framework with Oracle as Db
I will be starting an ASP.NET MVC 4 project soon with Entity Framework as my ORM and Oracle as my database engine. 我将很快以Entity Framework作为我的ORM和Oracle作为我的数据库引擎开始一个ASP.NET MVC 4项目。
I know that in order to get EF to work with Oracle, the tables have to be manually created in Oracle and the entities mapped to the table column by column. 我知道,为了使EF与Oracle一起使用,必须在Oracle中手动创建表,并将实体逐列映射到表。
The problem is my application has Authentication and Authorization needs and I was wondering what the easiest way would be to get the .NET membership to work with my scenario. 问题是我的应用程序具有身份验证和授权需求,我想知道最简单的方法是使.NET成员资格与我的方案一起工作。
I have found this article , but it makes use of third party software that I find expensive. 我已经找到了这篇文章 ,但是它利用了我认为昂贵的第三方软件。
I am using Oracle Developer Tools for .NET (ODT), and it has been a great help. 我使用的是.NET (ODT)的Oracle开发人员工具 ,它对您有很大的帮助。 The best part: it's free! 最好的部分:它是免费的! ODT includes ODP.NET and will help you do the following: ODT包括ODP.NET,它将帮助您执行以下操作:
Some things to consider... My membership schema is separate from the schemas used for my application. 需要考虑的一些事情...我的成员资格架构与用于我的应用程序的架构是分开的。 This way I can use one membership schema for several applications that may rely on different databases (schemas/users). 这样,我可以将一个成员资格架构用于可能依赖于不同数据库(方案/用户)的多个应用程序。
When configuring web.config, be sure to change the application name from "/" to something meaningful. 配置web.config时,请确保将应用程序名称从“ /”更改为有意义的名称。 Several config elements reference the application name, so be sure to change for all. 几个配置元素引用了应用程序名称,因此请确保全部更改。 The membership provider will automatically create the application record in the membersip database schema. 成员资格提供者将在membersip数据库模式中自动创建应用程序记录。
After your membership schema has been created (with the scripts), you'll need to change the web.config file's membership, profile, and roleManager elements to something like this: 创建成员资格架构(使用脚本)之后,需要将web.config文件的成员资格,配置文件和roleManager元素更改为以下内容:
<membership defaultProvider="OracleMembershipProvider">
<providers>
<clear />
<add name="OracleMembershipProvider" type="Oracle.Web.Security.OracleMembershipProvider, Oracle.Web, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="OraAspNetConnectionString" applicationName="YOUR_APP_NAME" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="5" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression="" />
</providers>
</membership>
<profile>
<providers>
<clear />
<add name="OracleProfileProvider" type="Oracle.Web.Profile.OracleProfileProvider, Oracle.Web, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionStringName="OraAspNetConnectionString" applicationName="YOUR_APP_NAME" />
</providers>
</profile>
<roleManager enabled="true" defaultProvider="OracleRoleProvider">
<providers>
<clear />
<add connectionStringName="OraAspNetConnectionString" applicationName="YOUR_APP_NAME" name="OracleRoleProvider" type="Oracle.Web.Security.OracleRoleProvider, Oracle.Web, Version=4.112.3.0, Culture=neutral, PublicKeyToken=89b483f429c47342" />
</providers>
</roleManager>
This link may also help 此链接也可能有帮助
Hope this helps. 希望这可以帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.