执行code首先迁移 [英] Execute Code first Migration
问题描述
我已经安装了Windows 8.1 Pro和使用VS 2013社区版感动了所有MVC项目,以新的工作空间。所有项目都是使用code第一次迁移。
数据库发布使用code第一次迁移也做。所有运行良好我更新了我的机器前。
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.
但现在,当我发布web应用到远程服务器,发布网站对话框不显示执行code第一次迁移,而不是它的表现更新数据库更新数据库。
当我关闭它,它会修改发布文件DB第一。看来,一些全局设置,它执行以下code:
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>
没有显示我的所有项目它的奇怪为什么执行code第一次迁移。
Its strange why "Execute Code first Migration" is not shown for all my projects.
此行为是一样的我所有其他项目了。
This behavior is same for all my other projects too.
App_Data文件数据库还没有打开。因此,我改变的connectionString'数据源从数据源=(的LocalDB)\\ V11.0 到数据源=(的LocalDB)\\ MSSQLLocalDB(MSSQL Sever的2014前preSS) 。更改数据源工作虽然打开数据库。
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.
我试过的解决方案:
- 尝试这样做:<一href=\"http://stackoverflow.com/questions/19664459/execute-$c$c-first-migrations-checkbox-disappeared-from-my-publish-profile\">"Execute code首先迁移&QUOT;复选框从我的发布配置 消失
- 启用迁移-Force
- 清洁,重建并重新启动项目,
Visual Studio中。 - 删除并重新导入文件发布
我试过上面几个月前解决方案。彼时上述几点工作,但现在没有什么工作。
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.
推荐答案
我发现这是一个临时解决方案。手动替换所有的ConnectionString名(Defaultconnection)上下文名ApplicationDbContext没有命名空间解决了这个问题。
I found a temporary solution for this. Manually replacing all ConnectionString name (Defaultconnection) to context name "ApplicationDbContext" without namespaces solved the problem.
这篇关于执行code首先迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!