且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Azure的EF code首先迁移初始化器

更新时间:2023-02-07 15:14:57

我想你错过了 在你的字符串类型:

I think you're missing a . in your type string:

<databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion">

红色矩形在code使得它很难读...

The red rectangle over the code makes it hard to read...

如果是行修复,发表评论,我会工作的一个样本,以配合你,看看我能得到它的工作...

If that doest fix it, post a comment and I'll work up a sample to match yours and see if I can get it to work...

[更新日期2012-08-15]

确定 - 我想我知道是怎么回事......你提到的我更新我的web.config有这样的:和你的表现XML。当我通过教程跑了,我没有进入任何额外的XML到我的的web.config 。在发布过程中,对我来说是由Visual Studio的部署过程中添加的XML自动的,这一切只是工作。

OK - I think I know what's going on here... You mentioned "I updated my web.config to have this:" and showed your XML. When I ran through the tutorial, I did NOT have to enter ANY extra XML into my web.config. During the publishing process, the XML was added for me automagically by Visual Studio's deployment process and it all "just worked".

这是你的解决方案:

返回到原来的的web.config 文件没有这些更新,然后再发布一次。

Go back to the original web.config file without these updates, and try publishing again.

有关参考,在这里是&LT;的EntityFramework&GT; 从我的两个的web.config节文件,首先从我的项目,第二个从我的托管服务(我通过通过FTP连接到正在运行的网站,并下载它)。该VS项目被称为 11964172 后这个职位的SO备案号:

For reference, here are the <entityFramework> sections from my two web.config files, first from my project, second from my hosted service (I got that by connecting to the running site via FTP and downloading it). The VS project is called 11964172 after the SO record number for this post:

本地的web.config 文件设置

local web.config file settings

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>

部署的web.config 文件设置

deployed web.config file settings

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <contexts>
      <context type="_11963331.Models.ToDoDb, 11963331">
        <databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion`2[[_11963331.Models.ToDoDb, 11963331], [_11963331.Migrations.Configuration, 11963331]], EntityFramework, PublicKeyToken=b77a5c561934e089">
          <parameters>
            <parameter value="_11963331.Models.ToDoDb_DatabasePublish" />
          </parameters>
        </databaseInitializer>
      </context>
    </contexts>
  </entityFramework>

我想这就是为什么他们采取的的web.config 文件更改的图片,而不是实际提供code可以键入: - )

I guess that explains why they took a picture of the web.config file changes instead of actually providing the code to type in :-)