[. Net MVC] Using SQL Server databases instead of LOCALDB

Source: Internet
Author: User
Tags management studio microsoft sql server management studio sql server management sql server management studio

Before the development of the time has been used VS2013, so the database is also used LocalDB, which brings great convenience for development. However, due to deployment after development, SQL Server 2012 is used instead, and the next procedure is summarized here.

Basic Environment: Vs2013,ef Code first,sql Server 2012,win7.

Modifying the domain-level app. Config is the project that originally generated the database with EF Code First, with LocalDB, the EF node and the connection string node:

<EntityFramework><DefaultconnectionfactoryType= "System.Data.Entity.Infrastructure.LocalDbConnectionFactory, entityframework"><Parameters><ParameterValue= "v11.0"/></Parameters> </ Defaultconnectionfactory> < providers> <provider invariantname = " System.Data.SqlClient " type =" System.Data.Entity.SqlServer.SqlProviderServices, entityframework.sqlserver "/>" Span style= "COLOR: #0000ff" ></providers></entityframework>  
<= "Siaems"= "Data source= (LocalDb) \v11.0; AttachDbFileName = | Datadirectory|\siaems.mdf;initial Catalog = siaems;integrated Security = True "=" System.Data.SqlClient "/> 

With SQL Server, you need to modify these two nodes:

<EntityFramework><Defaultconnectionfactorytype = " System.Data.Entity.Infrastructure.SqlConnectionFactory, entityframework "/> <providers> <provider invariantname =" System.Data.SqlClient " type =" System.Data.Entity.SqlServer.SqlProviderServices, entityframework.sqlserver "/>" Span style= "COLOR: #0000ff" ></providers></entityframework>  
<name= "Siaems"      connectionString= "Data Source =." Initial Catalog = Siaems; user = sa; Password = ******; Multipleactiveresultsets = True; APP = entityframework "providerName=" System.Data.SqlClient "/>      

The contents of the connection string need to be noted, the server-side address of the data source fills the database, if it is native. Initial Catalog is the name of the database to connect to; Here, use SQL Server authentication, fill in user and password Integrated Security is not set here, if set to True, the Windows Authentication mode will be used, and the previously filled U and P do not work The Multipleactiveresultsets function is to specify whether a multi-activity result set is associated with a specified link, and true is associated with the specified link, which can be used to reduce the burden on the system.

Then modify the connection string under the Web. config for the startup project, and modify the same as above.

To do this, complete the configuration that needs to be modified. Next, you need to build the database, open the Tools->nuget Package Manager console in VS2013, select the project for the domain layer in the default project, and use enable-migrations,add-migration in turn, The update-database command generates a database file.

When you install SQL Server, you need to modify it in Microsoft SQL Server Management Studio because you chose the Windows Authentication logon database. Open Manager, after logging in as Windows, right-click Properties---security on the server, select SQL Server and Windows Authentication mode in Server Authentication, OK exit. Click Security under Server, login name, right-click the SA property, and then OK after entering the password in general. Ben came here thought it was finished, but also need to restart the service, only to enable the configuration to take effect, because did not take this step, after deployment, browse the site, has been shown that the database login failed. Right-click on the server, restart, pop-up dialog, point is OK.

[. Net MVC] Using SQL Server databases instead of LOCALDB

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.