This site uses cookies to deliver our services. By using this site, you acknowledge that you have read and understand our Cookie and Privacy policy. Your use of Kontext website is subject to this policy. Allow Cookies and Dismiss

[WebMatrix] [MVC]迁移数据库至SQL Server

458 views 0 comments last modified about 7 years ago Raymond Tang Fahao

In this page


翻译者: Raymond Tang

迁移数据库至SQL Server

本演练演示如何从微软的SQL Server Compact4.0数据库迁移到SQL Server Express或SQL Server。


· 如何使用WebMatrix数据库工作区中的迁移功能。

· 如何安装SQL Server Express,如果你的计算机上未安装。

· 如何进行迁移,并验证其成功。


要运行此过程中的步骤,您必须运行于Windows XP SP3或更高版本的Windows。你还需要安装WebMatrix。有关如何安装WebMatrix的信息,请参阅Microsoft Web Platform Installer


迁移到SQL Server,你可以使用SQL Server的功能,如存储过程和它的附加功能,比如处理超过256个并发连接或大于4 GB的数据库。本演练演示如何将Microsoft SQL Server Compact 4.0数据库(.sdf文件)转换到SQL Server Express或SQL Server。这与将数据库发布到一个公共Web服务器上作为你的网站的一部分是不同的。有关信息,请参阅”如何使用WebMatrix发布一个web应用程序”( How to publish a web application using WebMatrix.)。

迁移到SQL Server

1. 在WebMatrix中,打开有你要迁移的数据库的网站。如果你没有一个带有数据库的网站,并且你只是想尝试迁移功能,单击快速启动屏幕上的从模板创建网站(Site From Template)选项,然后选择Bakery模板。此模板的网站,包括数据库。

2. 选择数据库工作区,并选择要迁移的数据库。在这个例子中,我们选择bakery.sdf。 (如果您没有看到在你的数据库中列出,请右键单击该站点,然后单击“刷新”。)

3. 在“主页”( Home)选项卡,单击“迁移”( Migrate)按钮并显示迁移数据库(Migrate Database)对话框。


4. 如果你未安装SQL Server,迁移数据库对话框将显示一个链接,让你现在安装SQL Server Express 2008。如果你需要安装它,点击链接。在安装过程中,将提示您选择身份验证模式。现在,选择Windows身份验证。稍后你可以更改此设置。

当你已完成安装后,只有当你是迁移到另一台计算机上的SQL Server Express实例,或迁移到SQL Server(非Express版本),或者如果你需要使用SQL Server登录,你可以在迁移数据库对话框更改默认设置。默认情况下,迁移到本机的SQL Server Express实例。


5. 点击“确认”(OK)按钮。





· 创建SQL Server Express数据库和迁移架构以及数据。

· 更名原bakery.sdf文件为bakery.sdf.backup。

· 更新Web.config文件中的连接字符串。如果你没有一个连接字符串,WebMatrix将创建了一个,并把它命名为与.sdf文件名相同且不带扩展名。 (在本例中为“bakery”。)如果你使用Database.Open方法连接数据库,代码将仍然正常工作,因为WebMatrix如果不能找到一个bakery.sdf文件,它将自动寻找名为“bakery”的连接字符串。

Related pages

Issue - Unable to get property 'apply' of undefined or null reference occurred in Angular 4.*, VS2017 15.3, ASP.NET Core 2.0

6162 views   10 comments last modified about 2 years ago

Issue Context After installed Visual Studio 2017 15.3 preview and .net core 2.0 preview SDK, I upgraded one of my existing core project to 2.0. The project was created using ‘dotnet new angular’ SPA template.  I also upgraded all the client app packages to the latest. For exa...

View detail

Retrieve Identity username, email and other information in ASP.NET Core

683 views   0 comments last modified about 9 months ago

The identity system in ASP.NET has evolved over time. If you are using ASP.NET Core, you probably found User property is an instance of ClaimsPrincipal in Controller or Razor views. Thus to retrieve the information, you need to utilize the claims.

View detail

Retrieve Azure AppSettings and Connection String Settings in ASP.NET Core Apps

1178 views   0 comments last modified about 9 months ago

In ASP.NET Core, we can easily use user secrets to manage our password or credentials. This post will summarize the approaches we can use after the websites are deployed into Azure.

View detail

Server.MapPath Equivalent in ASP.NET Core 2

3525 views   0 comments last modified about 9 months ago

In traditional applications, Server.MapPath is commonly used to generate absolute path in the web server. However, this has been removed from ASP.NET Core. So what is the equivalent way of doing it?

View detail

Migrating from ASP.NET Core 1.x to ASP.NET Core 2.0

883 views   2 comments last modified about 10 months ago

Migrating from ASP.NET Core 1.x to 2.0 is not an easy job especially if you have customized Identity and used customized authentication. This post summarizes the issues and errors I have experienced and their resolutions when upgrading my project. Hopefully it can save you sometime if you are doi...

View detail

OpenIddict Refresh Token Flow issue ASP.NET Core 2.0

1027 views   0 comments last modified about 10 months ago

Context When I followed OpenIDDict refresh flow sample, I constantly got the issue “The refresh token is no longer valid”, which is returned by the following code in my authorization web api controller: result.Content = new OpenIdConnectResponse  &...

View detail

Add comment

Please login first to add comments.  Log in New user?  Register

Comments (0)

No comments yet.