如何使用SimpleMembership MVC中没有实体框架 [英] How to use SimpleMembership in MVC without Entity Framework

查看:122
本文介绍了如何使用SimpleMembership MVC中没有实体框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

需要什么样的步骤来使用SimpleMembership(ASP.NET MVC 4)RavenDB(或其他数据库),而不是SQL Server的?

What are the required steps to use SimpleMembership (ASP.NET MVC 4) with RavenDB (or other databases) instead of SQL Server?

我用覆盖的MembershipProvider但它是如何与新的SimpleMembership工作?

I am used to override the MembershipProvider but how does it work with the new SimpleMembership?

我看到有一个SimpleMembershipProvider,所以我想我应该覆盖它,但我不知道是否该方法仅用于存储数据的目的,他们是否应该包含业务/验证逻辑)...

I saw there is a SimpleMembershipProvider so I think I should override it, but I don't know if the methods are for storing data purpose only or if they should contain business/validation logic)...

有关配置是什么?我知道InitializeDatabaseConnection方法通常用于初始化整个事情负责,但我不认为我应该称呼它,如果我不使用实体框架。

What about configuration? I know the InitializeDatabaseConnection method is normally responsible for initializing the whole shebang, but I don't think I should call it if I don't use Entity Framework.

不幸的是,我没有找到很多的资源,除了左右两个环节的新SimpleMembership这并不十分有用:

Unfortunately, I did not find a lot of resources about the new SimpleMembership except two links which have not been very useful:

<一个href=\"http://igambin.blogspot.ca/2012/08/simplemembershipprovider-huh.html\">http://igambin.blogspot.ca/2012/08/simplemembershipprovider-huh.html

<一个href=\"http://blog.osbornm.com/archive/2010/07/21/using-simplemembership-with-asp.net-webpages.aspx\">http://blog.osbornm.com/archive/2010/07/21/using-simplemembership-with-asp.net-webpages.aspx

推荐答案

因此​​,这里是我在看一些源$ C ​​$ C(MVC4)后发现。

So here is what I found after looking at some of the the source code (MVC4).

<一个href=\"http://aspnetwebstack.$c$cplex.com/SourceControl/changeset/view/553690ac9488#src%2fWebMatrix.WebData%2fExtendedMembershipProvider.cs\">http://aspnetwebstack.$c$cplex.com/SourceControl/changeset/view/553690ac9488#src%2fWebMatrix.WebData%2fExtendedMembershipProvider.cs

SimpleMembership是抽象类ExtendedMembershipProvider的实现。
里面SimpleMembership的code主要是SQL操作和底层的MembershipProvider(称为文档previous)几个电话。

SimpleMembership is an implementation of the abstract class ExtendedMembershipProvider. The code inside SimpleMembership is mostly SQL operations and some calls to the underlying (called "previous" in the documentation) MembershipProvider.

我不认为这是任何使用(在我的情况)来覆盖SimpleMembership作为其实现主要是绑到SQL Server。相反,我的理解,我应该实现ExtendedMembershipProvider。然后,通过在web.config文件中设置此实现中,WebSecurity助手将绕过SimpleMembership(默认实现),并叫我实施ExtendedMembershipProvider的。

I don't think it is of any use (in my case) to override SimpleMembership as its implementation is mostly tied to SQL Server. Instead, for what I understand, I should implement ExtendedMembershipProvider. Then, by setting this implementation in the web.config file, the WebSecurity helper would bypass SimpleMembership (default implementation) and call my implementation of the ExtendedMembershipProvider.

我不觉得,因为它看起来比以前更加复杂(更多的方法来实现)...但还是可行的,我会很快的任何做到这一点。

I don't think I will do this any soon since it looks even more complicated than before (more methods to implement)... but still doable.

然而,这一切说,我有点失望的是,我们仍然有工作在的MembershipProvider 其中,恕我直言,是远(很多静态的和内部的东西)从整体上依赖我们爱这么多与ASP.Net MVC /注射的WebAPI的东西。

However, all this said, I'm a bit disappointed that we still have to work with the MembershipProvider which, IMHO, is far (a lot of static and internal stuff) from the whole dependency injection thing that we love so much with ASP.Net MVC/WebApi.

修改1

这个问题被aked之前乔恩·加洛韦写过这个教程:
<一href=\"http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx\">http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx

This question was aked before Jon Galloway wrote this tutorial : http://weblogs.asp.net/jgalloway/archive/2012/08/29/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates.aspx

但我的回答保持有效,因为这(乔恩加洛韦文章所)恢复它:

But my answer stays valid as this (taken from Jon Galloway article) resumes it:

注意SimpleMembership仍然需要SQL Server的一番风味 -
  它不会与MySQL,NoSQL数据库等工作,你可以看看
  在code在WebMatrix.WebData.dll使用,如果你想ILSpy工具
  想知道为什么 - 有些地方的SQL Server特定的SQL
  语句被执行,特别是当创建和
  初始化表。好像你也许能够一起工作
  另一个数据库,如果你创建的表分开,但我没有
  试了一下,它不是在这一点上的支持。

Note that SimpleMembership still requires some flavor of SQL Server - it won't work with MySQL, NoSQL databases, etc. You can take a look at the code in WebMatrix.WebData.dll using a tool like ILSpy if you'd like to see why - there are places where SQL Server specific SQL statements are being executed, especially when creating and initializing tables. It seems like you might be able to work with another database if you created the tables separately, but I haven't tried it and it's not supported at this point.

这篇关于如何使用SimpleMembership MVC中没有实体框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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