我可以将 Entity Framework 与 ASP.NET 成员身份一起使用吗? [英] Can I use Entity Framework with ASP.NET Membership?

查看:36
本文介绍了我可以将 Entity Framework 与 ASP.NET 成员身份一起使用吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建(实际上是重新创建)一个应用程序,该应用程序在 MS-Access 数据库中具有现有用户和其他数据.数据将移动到 SQL Server,其中一部分涉及迁移用户.我想使用 EF 来做 ORM,而且我很确定我知道 SQL Server 中的数据模型是什么.我是 EF 的新手,但不是 ASP.NET,我想利用 ASP.NET 中的成员资格功能.我正在考虑几种方法来做到这一点,并希望得到一些建议.到目前为止,我只对这个想法做了一点研究,也许它在其他地方得到了回答.所以,这里有一组相关的问题.

I'm creating (really, re-creating) an app that has existing user and other data in MS-Access databases. The data will be moved to SQL Server, and part of that involves migrating users. I want to use EF to do ORM, and I am pretty sure I know what the data model will be in SQL Server. I am new to EF but not to ASP.NET, and I'd like to take advantage of the Membership features in ASP.NET. I am thinking about several ways to do this and would like some advice. I've done only a little research about this idea thus far, maybe it's been answered elsewhere. So, here goes a cluster of related questions.

  1. EF 能否通过一些我不知道的类或命名空间直接与 ASP.NET Membership 一起使用?

  1. Can EF work with directly with ASP.NET Membership through some class or namespace that I'm not aware of?

如果我将用户转换到会员系统,为了使他们的用户 ID 与其他表中的数据保持一致,我是否应该在 aspnet_* 表(如 DotNetNuke)上为用户数据创建另一组表?

If I transition users to the Membership system, to align their userids with data in other tables should I create another set of tables for user data atop the aspnet_* tables a la DotNetNuke?

我想避免出现以下情况:我使用内置的成员身份函数仅进行用户身份验证,并在处理用户标记数据时切换到 EF 上下文.通过为每一行进入 Membership 用户来撤回用户信息以绑定到 GridView 中的列似乎很笨拙,但也许这就是所需要的?为了数据检索的目的,我是否需要把它搞定并复制 EF 中的 Membership 类?

I want to avoid a situation where I use the built-in Membership functions for only user authentication and switch over to EF context when I'm working with user-tagged data. Seems clumsy to withdraw user info to bind to a column in a GridView by going into a Membership user for every row, but maybe that's what's needed? Do I need to suck it up and replicate the Membership classes in EF for data retrieval purposes?

我正在考虑可能为会员实现某种 EF 提供程序,因为那时提供程序可能会位于整个 EF 数据模型中.这是疯话吗?(我以前从未编写过自己的提供程序)

I was thinking of maybe implementing some kind of EF provider for Membership, on the idea that maybe then the provider could sit inside the overall EF data model. Is this crazy talk? (I've never written my own provider before)

随意告诉我我没有任何意义.

Feel free to tell me I am not making any sense.

推荐答案

为什么不反过来呢?您可以为 asp.net 实现自己的 Membership 提供程序,该提供程序使用您想要/需要的模型.

Why not do it the other way around? You can implement your own Membership provider for asp.net, that uses the model you want/need.

如果您需要的功能与内置的 asp.net 成员资格实现不完全匹配,您可以推出自己的提供程序.如果您将只使用几个功能,您将只需要实现几个方法(您不必为所有方法填写实现).如果您需要的功能超出其支持范围,则使用会员服务提供商可能会妨碍您.

If the features you need aren't a complete match with the built-in asp.net membership implementation, you can just roll your own provider. If you will use just a couple features, you will have to implement just a couple methods (you don't have to fill implementation for all the methods). If you need more features than it supports, using the membership provider might get in your way.

这篇关于我可以将 Entity Framework 与 ASP.NET 成员身份一起使用吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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