Scenario: SharePoint Projects (other types of items are the same), the database was created with EF (version: 6.0.0.0), the production environment is already in use, so subsequent modifications to the database can only be achieved by updating.
Here's how to do it:
1. Visual Studio opens the project and opens the package management console.
How to: View--Other Windows--Package management Console
2, the project "References" in the EntityFramework.SqlServer.dll and EntityFramework.dll the properties of the two files to be copied to the local
How to: Select the file--Press "copy to local" in the f4--Properties dialog box and choose True
3. In the project configuration file, configure the database connection string.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="ConnectName" connectionString="data source=111.111.111.111;initial catalog=TestDB;user id=sa;password=123;MultipleActiveResultSets=True;App=EntityFramework;Connect Timeout=3600;" providerName="System.Data.SqlClient" />
</connectionStrings>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
<parameters>
<parameter value="mssqllocaldb" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
4. Execute the following command in the "Package Management Console" order
Enable-Migrations
Add-Migration
Update-Database
5, all smooth, congratulations, the database updated successfully!
6, pay attention to the target platform of project generation, select "Any CPU".
How to do this: Select the item-Properties--in the Open Interface, change "target platform" to "any CPU"
7, after the completion of the update, it is best to make an appeal to modify the document, there is also the operation of the project in the new addition of the file to delete the good.
Database created using EF in Visual Studio projects, subsequent update database operations (production already deployed, cannot delete database re-created)