简体   繁体   English

ASP.NET MVC4和Entity Framework中的.NET成员资格,Oracle为Db

[英].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,它将帮助您执行以下操作:

  • automatically set up ASP.NET membership tables. 自动设置ASP.NET成员资格表。 You'll need to create the schema first, then run the scripts provided. 您需要先创建架构,然后运行提供的脚本。
  • automatically create and map EF entities (using database first); 自动创建和映射EF实体(首先使用数据库); you will not need to manually map tables to tables. 您将不需要手动将表映射到表。

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.

相关问题 ASP.Net MVC4会员资格 - ASP.Net MVC4 Membership ASP.NET MVC4 和实体框架上的超时问题 - Timeout issue on ASP.NET MVC4 and Entity Framework 使用实体框架对ASP.NET MVC4进行单元测试 - Unit testing asp.net mvc4 with Entity Framework 实体框架Codefirst和ASP.NET成员资格 - Entity Framework Codefirst and ASP.NET Membership Controller中的ASP.NET MVC实体框架DB访问 - ASP.NET MVC Entity Framework DB access in Controller 在 LINQ Entity Framework asp.net MVC 5 中切换数据库上下文 - Switching DB Context in LINQ Entity Framework asp.net MVC 5 ASP.NET MVC2和Entity Framework 4从数据库生成模型,而无需复制成员资格模型 - ASP.NET MVC2 and Entity Framework 4 Generating Model from Database without duplicating Membership Models 实体框架分析器 - 带有EF 6的ASP.NET MVC4 - 无法确定提供者名称 - Entity Framework profiler - ASP.NET MVC4 with EF 6 -Unable to determine the provider name 具有实体框架的ASP.NET MVC4在编辑操作中未传递字段 - ASP.NET MVC4 with Entity Framework not passing fields in Edit operation 如何使用带有Entity Framework的ASP.net MVC4上传/显示图像 - How to upload/display images using ASP.net MVC4 with Entity Framework
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM