改变 ASP.NET MVC 框架自动生成的数据库是个好主意吗?

发布于 2024-07-13 00:49:11 字数 207 浏览 4 评论 0原文

将 aa 列添加到自动生成的 asp.net(ASPNETDB.MDF、Visual Studio 2008、mvc 框架)“用户角色 - 数据库”中是一个坏主意(如果是为什么?)?

(例如,我想将 RealName 和 LastName 列添加到数据库中的 aspnet_Users 表中。)

我想添加列而不是创建整个新表的原因是为了避免双维护问题和不必要的冗余

Is it a bad idea (and if why?) to add a a column to the auto generated asp.net (ASPNETDB.MDF, visual studio 2008, mvc framework) "user roles - database"?

(E.g I want to add the columns RealName and LastName to the aspnet_Users table in the database.)

The reason I want to add a column instead of creating an entire new table is to avoid the doule maintenance issue and unnecessary redundancy

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

姜生凉生 2024-07-20 00:49:11

使用两种生成方案(来自 实用程序员

  • :用于生成代码一次
  • 用于同步某些代码的

那些 用于同步的结果不应修改,因为稍后生成再次完成时它们可能会被覆盖。

对于生成的 asp.net 数据库,没有理由重新运行生成,因此编辑它就可以了。

您将重新运行数据库生成的唯一情况是,如果微软发布了新版本的用户数据库并且您想要使用新版本(在这种情况下,您可能必须编辑应用程序的某些部分,因此您可以readd 这两个字段),或者如果您想使用不同的选项重新生成数据库。 如果您对当前的数据库不满意,这两种情况都会发生。

There are two generation schemes that are used (from Pragmatic Programmer):

  • Those that are used once to generate code
  • Those that are used all the time to have some code synced

The ones that are used for syncing, the results should not be modified, since they could be overridden at a later date when the generation gets done again.

In the case of your generated asp.net database, there is no reason for you to rerun the generation, so it would be OK to edit it.

The only scenario under which you would rerun the generation of the db is if microsoft releases a new version of the users database and you want to use the new one (in this case you might have to edit some parts of your application, so you could readd those two fields), or if you want to regenerate the database with different options. Both of these happen if you are not happy with your current db.

沩ん囻菔务 2024-07-20 00:49:11

在我看来,自动生成的数据库应该被应用程序数据库中的普通表取代,或者至少应该有一个官方的解决方案来解决这个问题。

我听说这是一个非常好的解决方案: http://www.asp.net/downloads/sandbox/table-profile-provider-samples/" rel="nofollow noreferrer"> asp.net/downloads/sandbox/table-profile-provider-samples/

In my opinion that autogenerated database should be replaced by a normal table in application database or at least there should be an official solution to this problem.

I heard that this is quite good solution: http://www.asp.net/downloads/sandbox/table-profile-provider-samples/

黑色毁心梦 2024-07-20 00:49:11

为什么不创建一个带有外键约束的新表? 向 aspnetdb 添加一列似乎是一个坏主意...如果您需要重新创建数据库,这将是一场噩梦...

why dont you create a new table with a Foriegn Key restraint? It seems like a bad idea to add a column to the aspnetdb...it will be a nightmare if you ever need to recreate your db...

始终不够 2024-07-20 00:49:11

首先,这些表实际上并不是 MVC 特有的:它们是由默认的 AspNetSqlMembershipProvider。 (也适用于其他类型的 ASP.NET 应用程序。)

您可能可以安全地添加新列,但成员资格提供程序不会“看到”它们。 它确实提供了配置文件机制来存储额外信息(这些信息被序列化并存储在 aspnet_Profiles 表中)。

如果您需要存储有关用户的大量其他信息,您还可以查看 此示例会员资格提供程序将个人资料信息存储在一流的表中,而不是个人资料 blob 中。

First, those tables aren't really anything specific to MVC: they're created by/for the default AspNetSqlMembershipProvider. (Also applies to other kinds of ASP.NET applications.)

You could probably add new columns safely, but the membership provider wouldn't "see" them. It does provide its profile mechanism to store extra information (which gets serialized, and stored in the aspnet_Profiles table).

If you need to store lots of additional information about the user, you might also check out this sample membership provider that stores profile information in first-class tables, rather that in profile blobs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文