如何最好地利用ASP .NET Membership数据库?

时间:2022-10-27 13:05:16

I'm in early development stage of developing a web application. Im currently reviewing as to whether I should use ASP .NET Membership or write my own. Im more lenient towards to using ASP .NET Membership to save me some development time. Need help to clear up some ambiguities on how to best utilize membership database:

我正处于开发Web应用程序的早期开发阶段。我目前正在审查是否应该使用ASP .NET Membership或编写我自己的。我更倾向于使用ASP .NET Membership来节省一些开发时间。需要帮助以澄清如何最好地利用成员资格数据库的一些含糊之处:

  • Membership creates a new database. Which one is better, to use the same database for my application database OR creating a new database for my application? Why?
  • 成员资格创建新数据库。哪一个更好,为我的应用程序数据库使用相同的数据库或为我的应用程序创建一个新的数据库?为什么?

  • If I go for creating a new database for my application. Which one is better, creating a new user table in my application database or reusing/extending the user table in the membership database?
  • 如果我为我的应用程序创建一个新数据库。哪一个更好,在我的应用程序数据库中创建一个新的用户表,或者在成员资格数据库中重用/扩展用户表?

Thanks in advance,

提前致谢,

RWendi

2 个解决方案

#1


5  

I myself am a fan of the Membership/Roles/Profile providers so I'm a bit biased. Basically if I were to evaluate what to use for a project I would look at the requirements. I can see no reason to implement your own membership functionality if the default works for you. It has many features and some pretty good optimizations (like columns with lowercase username and email for performance reasons).

我自己是会员/角色/个人资料提供者的粉丝,所以我有点偏颇。基本上,如果我要评估项目的用途,我会查看要求。如果默认适用于您,我认为没有理由实施您自己的会员功能。它具有许多功能和一些非常好的优化(例如,出于性能原因,使用小写用户名和电子邮件的列)。

I usually create a single database for my data and my membership. I link other tables by adding a username column but not a foreign key to avoid problems with deleting users. What is more the GUID that is the user id cannot be retrieved with the membership provider interface and you will need to write your own stored procedure if you want to reference stuff by user id.

我通常为我的数据和会员资格创建一个数据库。我通过添加用户名列而不是外键来链接其他表,以避免删除用户时出现问题。更重要的是,无法使用成员资格提供程序接口检索用户标识的GUID,如果要按用户标识引用内容,则需要编写自己的存储过程。

#2


1  

On the question of separate database or not, separate tends to be the way to go if you have the resources (eg--you aren't on a shared host with a single sql server db). The main advantage is that the user data tends to be pretty application specific (eg--you don't need production user data in QA), so having it live separately makes things a bit cleaner as you only need to schlep about the application's data.

关于单独数据库的问题,如果你有资源(例如 - 你不在具有单个SQL服务器数据库的共享主机上),则单独分开。主要优点是用户数据往往是非常特定于应用程序(例如 - 您不需要在QA中生成用户数据),因此单独使用它会使事情变得更清晰,因为您只需要了解应用程序的数据。

#1


5  

I myself am a fan of the Membership/Roles/Profile providers so I'm a bit biased. Basically if I were to evaluate what to use for a project I would look at the requirements. I can see no reason to implement your own membership functionality if the default works for you. It has many features and some pretty good optimizations (like columns with lowercase username and email for performance reasons).

我自己是会员/角色/个人资料提供者的粉丝,所以我有点偏颇。基本上,如果我要评估项目的用途,我会查看要求。如果默认适用于您,我认为没有理由实施您自己的会员功能。它具有许多功能和一些非常好的优化(例如,出于性能原因,使用小写用户名和电子邮件的列)。

I usually create a single database for my data and my membership. I link other tables by adding a username column but not a foreign key to avoid problems with deleting users. What is more the GUID that is the user id cannot be retrieved with the membership provider interface and you will need to write your own stored procedure if you want to reference stuff by user id.

我通常为我的数据和会员资格创建一个数据库。我通过添加用户名列而不是外键来链接其他表,以避免删除用户时出现问题。更重要的是,无法使用成员资格提供程序接口检索用户标识的GUID,如果要按用户标识引用内容,则需要编写自己的存储过程。

#2


1  

On the question of separate database or not, separate tends to be the way to go if you have the resources (eg--you aren't on a shared host with a single sql server db). The main advantage is that the user data tends to be pretty application specific (eg--you don't need production user data in QA), so having it live separately makes things a bit cleaner as you only need to schlep about the application's data.

关于单独数据库的问题,如果你有资源(例如 - 你不在具有单个SQL服务器数据库的共享主机上),则单独分开。主要优点是用户数据往往是非常特定于应用程序(例如 - 您不需要在QA中生成用户数据),因此单独使用它会使事情变得更清晰,因为您只需要了解应用程序的数据。