问题描述:

I have installed Windows 8.1 pro and moved all MVC projects to new work-space using VS 2013 Community Edition. All projects were using code first migration.

Database Publishing was also done using code first migration. All was running fine before I updated my machine.

But Now when I publish web application to remote servers, 'Publish Web' dialog box not showing "Execute Code first Migration", Instead its showing "Update database" for updating database.

And when I close it, It modifies the publish files for DB First. It seems that some global setting enforcing it to the following code:

 <Objects xmlns="">

<ObjectGroup Name="DefaultConnection" Order="1" Enabled="False">

<Destination Path="" />

<Object Type="DbDacFx">

<PreSource Path="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MVC-20140923125211.mdf;Initial Catalog=MVC-20140923125211;Integrated Security=True" includeData="False" />

<Source Path="$(IntermediateOutputPath)AutoScripts\DefaultConnection_IncrementalSchemaOnly.dacpac" dacpacAction="Deploy" />

</Object>

<UpdateFrom Type="Web.Config">

<Source MatchValue="Data Source=(LocalDb)\MSSQLLocalDB;AttachDbFilename=|DataDirectory|\MVC-20140923125211.mdf;Initial Catalog=aspnet-MVC-20140923125211;Integrated Security=True" MatchAttributes="$(UpdateFromConnectionStringAttributes)" />

</UpdateFrom>

</ObjectGroup>

</Objects>

Its strange why "Execute Code first Migration" is not shown for all my projects.

This behavior is same for all my other projects too.

The App_Data databases also not opening. So I changed connectionString' datasource from Data Source=(LocalDb)\v11.0 to Data Source=(LocalDb)\MSSQLLocalDB (MSSQL Sever 2014 express). Changing DataSource worked for opening database though.

I tried the solutions:

  • Tried this : "Execute Code First Migrations" checkbox disappeared from my publish profile
  • Enable Migration -Force
  • Clean, Rebuild and restart project and

    Visual Studio.

  • Delete and re-import publish file

I tried solutions above few months back. That time the points above worked but now nothing works.

Is there any solution available for this? I wasted my whole day and still not found solution.

网友答案:

You need to install the Visual Studio update 4. Go to Extensions and updates under tools.

网友答案:

You might find this helpful:

Entity Framework Code First Data Migrations not working with VS2012 Web Deploy

I myself am still trying to find a simple way to deal with migrations.

网友答案:

I found a temporary solution for this. Manually replacing all ConnectionString name (Defaultconnection) to context name "ApplicationDbContext" without namespaces solved the problem.

相关阅读:
Top