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

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

原文地址: http://www.microsoft.com/web/post/migrate-a-database-to-sql-server

翻译者: Raymond Tang http://kontext.tech/

迁移数据库至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)对话框。

clip_image001

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

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

clip_image002

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

WebMatrix开始启动你的架构(表定义)和数据迁移的过程。在执行迁移和迁移完成时,它在屏幕底部的通知栏显示状态消息。

clip_image003

这样就完成了。为了验证该网站在迁移后能正常运行,在菜单栏单击“运行”按钮。

以下是WebMatrix怎样转换数据库,以及使其对你的的网站可用:

· 创建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

7315 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 asp.net 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

3395 views   0 comments last modified about 2 years 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

2495 views   0 comments last modified about 2 years 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

7148 views   0 comments last modified about 2 years ago

In traditional asp.net 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

1433 views   2 comments last modified about 2 years 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

1507 views   0 comments last modified about 2 years 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.