如何将 ASPNETDB 数据库上传到服务器?
我已经上传了我的数据库备份并且工作正常。但由于我从 ASP.NET 配置创建了一个新用户,因此它将用户信息保存在 ASPNETDB 中。
我已经从 MVS 发布了我的数据库,并在 M SQL Server Management Studio 2008 中打开它来创建备份,但我没有在其中找到 ASPNETDB。
我的问题是:
当我上传数据库时,这个数据库不会自动上传吗?因为当我发布我的网站时它不会出现。
如果没有,我如何上传 ASPNETDB 以便我可以登录我的网站,因为我正在使用此用户的授权?
I have uploaded my database backup and it works fine. but since I've created a new user from ASP.NET Configuration I've that it saves the user information in the ASPNETDB.
I already published my database from MVS and open it in M SQL Server Management Studio 2008 to create the backup but I haven't find the ASPNETDB in it.
my question is:
doesn't this database just upload it automatically when I upload my database? coz when I publish my website it doesn't appear.
if not, How can I upload ASPNETDB so I can login to my site because I'm using authorization to this user ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
好吧,我将在这里做出一些假设并解释它们,因为这可能有很多事情:
假设 1(连接字符串问题)。在本地 sql 服务器上运行的数据库的用户凭据可能在您部署到的服务器上有效(似乎是世界的方式)尝试使用远程“已发布”中的凭据连接到远程数据库网站配置文件的副本。 (连接字符串)
假设2(发布设置不正确)。当您使用 Visual Studio 中的“发布”选项时,据我所知,您只能部署网站,但有人说您也可以配置它来部署数据库。
我建议在您的开发计算机上进行更改(例如,向 aspnet 数据库添加一个表),然后使用发布来查看该新表是否出现在远程服务器上,如果它没有转到 Visual Studio 中的服务器资源管理器并运行通过右键单击您的数据库并单击“发布到提供程序”向导,我倾向于将整个数据库推送到脚本文件,然后在远程数据库上手动运行该文件(似乎是最干净的选项)。
假设 3(数据库是否存在于服务器上)。我在这里可能是错的,但从你所说的看来,你将应用程序而不是数据库发布到服务器......这会导致一些漂亮的黄色服务器错误。
检查数据库是否存在,如果不存在...按照假设2中的建议进行操作并手动推送数据库。
Ok im gonna make a few assumptions here and explain them because this could be many things:
Assumption 1 (connection string issue). the user credentials for a database running on your local sql server are likely to be valid on the server on which you deploy to (seems to be the way of the world) try connecting to the remote database using the credentials in the remote "published" copy of the websites configuration file. (connection string)
Assumption 2 (publish settings not correct). when you use the "publish" option from within visual studio you only deploy the website to my knowledge but some say you can configure it to deploy the database as well.
I would suggest making a change (eg add a table to the aspnet database) on your dev machine then using publish to see if that new table appears on the remote server, if it doesn't go to the server explorer in visual studio and run the wizard by right clicking on your database and clicking on "publish to provider" i tend to push the entire db to a script file then manually run that on the remote database (seems the cleanest option).
Assumption 3 (does the database even exist on the server). I could be wrong here but from what you're saying it sounds like you published the application and not the database to the server ... that results in some nice yellow server errors.
Check that the database exists if not ... do as suggested in asumption 2 and push the database manually.
我想您正在使用会员 API。
如果您在装有 SQL Server Express Edition 的计算机上使用 ASP.NET,则当您创建第一个用户时,会自动为您创建 Membership API 底层数据存储所需的数据。此功能是通过 SqlMembershipProvider 提供的。 SqlMembershipProvider 会自动在网站的 App_Data 特殊目录中创建一个名为 ASPNETDB.MDB 的新数据库。该数据库实现了完整的模式,这是存储和管理用户信息、角色信息、用户角色分配等所必需的。
您可以轻松检查它。在您的 web.config 中,您应该看到类似以下内容:
因此该数据库应该已与您的网站一起上传。
请考虑这个教程如果您想在自己的数据库中创建 aspnetdb 或必要的表(这是一个很好的实践)。
也许您也会对此处的类似讨论感兴趣。此外,如果您仍然想在 SQL Server Management Studio 中获取此 .mdf 数据库,您可以了解如何附加数据库 这里。
I suppose you're using the Membership API.
If you are using ASP.NET on a machine with SQL Server Express Edition, the required by Membership API underlying data store is created automatically for you when you create the first user. This functionality is provided through the SqlMembershipProvider. The SqlMembershipProvider automatically creates a new database in the website’s App_Data special directory called ASPNETDB.MDB. This database implements the complete schema, which is necessary for storing and managing user information, role information, user-role assignments etc.
You can easily check it. In your web.config you should see something like:
So this database should have been uploaded along with your web site.
Please consider this tutorial if you want to create aspnetdb or necessary tables in your own database (which is a good praxis).
May be you will be also interested in the similar discussion here. Besides if you still want to get this .mdf database in SQL Server Management Studio you can learn how to attach a database here.