App_Data文件/ ASPNETDB.MDF到SQL Server 2005(或08) [英] App_Data/ASPNETDB.MDF to Sql Server 2005 (or 08)

查看:161
本文介绍了App_Data文件/ ASPNETDB.MDF到SQL Server 2005(或08)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发一个ASP.NET的WebForms应用程序,需要帐号登录功能(例如注册新用户,更改密码,找回密码,型材,角色等)。要做到这一点,我使用FormsAuthentication使用默认的数据存储,这,让我惊讶,是的App_Data一个MDF文件。当谈到时间,实际部署这个应用程序。生活在网络上,我将用一些共享主机例如GoDaddy或其他便宜的公司。

I've been developing an ASP.NET WebForms app that needed account login functionality (e.g. register new users, change passwords, recover passwords, profiles, roles, etc). To do this, I used FormsAuthentication with the default data store, which, to my surprise, is an MDF file in App_Data. When it comes time to actually deploy this app. live on the web, I'm going to use some shared hosting like GoDaddy or another cheap company.

为了提高效率,我想从这个MDF切换到实际的SQL Server 2005或2008(谁在心智正常使用纯文本文件?)。随着共享主机,不过,我不会要能够运行像aspnet_regsql.exe的任何程序。我只好到SQL Server数据库的一个登录名和密码,进入域根的FTP帐户​​。没有MSTSC远程桌面,无控制台访问,在IIS中没有修补等。

For efficiency, I'd like to switch over from this MDF to actual SQL Server 2005 or 2008 (who in their right mind uses flat files?). With shared hosting, however, I'm not going to be able to run any programs like aspnet_regsql.exe. I'll just have a single login and password to a SQL Server database, and an FTP account into the domain root. No MSTSC remote desktop, no console access, no tinkering in IIS, etc.

我不需要从ASPNETDB.MDF传送任何用户帐户(网站将用户数为0首发),但我怎么猜想:

I won't need to transfer any user accounts from ASPNETDB.MDF (site will be starting with zero users), but how am I suppose to:

1)轻松创建表,过程等可视化,当我用网站管理工具开始使用FormsAuthentication?在ASPNETDB.MDF自动创建工作室

1) Easily create the tables, procedures, etc. that Visual Studio automatically created in ASPNETDB.MDF when I used Web Site Administration Tool to get started with FormsAuthentication?

2)具有SQL成员资格提供程序使用连接字符串我给它,而不是使用任何现在连接到该ASPNETDB.MDF。该死的,我甚至不看任何连接字符串,这个MDF在web.config中;到底是怎么我的应用程序。即使找到了吗? Machine.config中?这将是一个糟糕的决定,如果是这样的话。这背后的幕后废话驱使我疯了。

2) Have the SQL membership provider use a connection string I give it instead of using whatever it is now to connect to this ASPNETDB.MDF. Hell, I don't even see any connection string to this MDF in the web.config; how the hell is my app. even finding it? Machine.config? That would be a poor decision if that's the case. This behind-the-scenes crap drives me nuts.

从别人的任何帮助谁已经通过这种迁移将是非常,非常AP preciated!

推荐答案

这MDF文件是一个SQL Server数据库。所有的SQL Server版本(除CE)使用相同的文件格式,因此密度板可以使用的 sp_attach_db的或SSMS,请参见如何:附加数据库(SQL Server Management Studio中)。。一旦连接到您的SQL Server,SSMS可以编写脚本整个数据库,请参见如何:生成脚本(SQL Server Management Studio中)。这也可以通过程序来完成,使用SMO 的编剧对象。该脚本SSMS将包含所有的表,索引,程序和数据库中的所有其他对象。还有一个导入和导出向导在SSMS ,然后你可以使用这个你的表内容(所有数据)导出到一个CSV文件,然后导入该CSV文件到您的托管数据库,但导入/导出向导是相当复杂的(它使用SSIS)。

That MDF file is a SQL Server database. All SQL Server versions (except CE) use the same file format, so the MDF can be opened by any other SQL Server using sp_attach_db or SSMS, see How to: Attach a Database (SQL Server Management Studio).. Once attached to your SQL Server, SSMS can script out the entire database, see How to: Generate a Script (SQL Server Management Studio). Also this can be done programatically, using the SMO Scripter object. The SSMS script will contain all the table, index, procedure and every other objects in the database. There is also an Import and Export Wizard in SSMS and you can use this to export your tables content (any data) into a CSV file and then import this CSV file into your hosted database, but that import/export wizard is fairly complex (it uses SSIS).

有关数据导出另一种方法是使用bcp实用程序,请参见批量导入和批量导出操作

Another alternative for the data export is to use bcp utility, see Bulk Import and Bulk Export Operations.

Tehcnically你可以斗使用SQL Server防爆preSS实例的所有这些操作在您的环境VS使用命令行工具,如SQLCMD和bcp,也许写自己的SMO的编剧应用导出数据库模式。但是,它需要的经验一定水平。这将是更容易吨有机会获得一个完全成熟的,上海管理Studio来$ P $削减所有的数据在您的主机站点进口。

Tehcnically you can doo all these operations using the SQL Server Express instance in your VS environment, using command line tools like sqlcmd and bcp, and perhaps writing your own SMO Scripter application to export the database schema. However, it requires a certain level of experience. It will be tonnes easier to have access to a fully fledged Managent Studio to preare all the data to be imported at your hosting site.

不要忘记检查你的供应商,如果他们允许恢复或附加自己的数据库,则可能蒙混过关容易,只需文件拷贝到提供者。

Don't forget to check with your provider if they allow to restore or attach your own database, then you may get away easy with just a file copy to the provider.

请注意,您的MDF文件,只可能将其附加到的至少相同版本的您与创建的一个SQL Server。你VS环境中包含一个SQL Server,可能命名为SQLEX preS,并且必须检查它到底是什么版本。是较早的版本比你的VS SQL实例的版本的服务器将拒绝附上您的MDF文件,因为它的他们根本没有识别的格式。按照 KB 321185 中的步骤,以确定您的VS环境有什么样的SQL Server版本。

Note that your MDF file will only be possible to attach it to a SQL Server of at least the same version as the one you have created with. You're VS environment contains a SQL Server, probably named SQLEXPRESS, and you must check exactly what version it is. Servers of an earlier build than your VS SQL instance version will refuse to attach your MDF file, since its a format they do no recognize. Follow the steps in KB 321185 to determine what SQL Server version your VS environment has.

更新

我不知道VS有一个导出向导。只要按照步骤<一个href=\"http://weblogs.asp.net/nannettethacker/archive/2008/11/04/deploying-the-aspnetdb-mdf-to-a-production-server.aspx\"相对=nofollow>加里提到的链接他提供。

I wasn't aware VS has an export wizard. Just follow the steps Gary mentions in the link he provides.

这篇关于App_Data文件/ ASPNETDB.MDF到SQL Server 2005(或08)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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