Azure的EF code首先迁移初始化器 [英] Azure EF Code First Migration Initializer

查看:116
本文介绍了Azure的EF code首先迁移初始化器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只是天青搞乱了,我似乎无法让我的数据库工作。我下面什么这里说的:的https://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/我更新了我的web.config中有这样的:

I am just messing with Azure, and I can't seem to get my Db to work. I am following what it says here: https://www.windowsazure.com/en-us/develop/net/tutorials/web-site-with-sql-database/ and I updated my web.config to have this:

  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
      <contexts>
          <context type="DownloadThis.Models.DownloadThisDb, DownloadThisDb">
              <databaseInitializer type="System.Data.Entity.MigrateDatabaseToLatestVersion">
                  <parameters>
                      <parameter value="DownloadThisDb_DatabasePublish" />
                  </parameters>
              </databaseInitializer>
          </context>
      </contexts>
  </entityFramework>

如上例所示,但我不断收到此错误:

As is shown in the example, but I keep getting this error:

初​​始化字符串的格式不符合规范
  从索引0开始。

Format of the initialization string does not conform to specification starting at index 0.

我已经三重检查我的connectionString,所以这不是它 - 任何想法

I have triple checked my connectionString, so that isn't it - any ideas?

推荐答案

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

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 :-)

这篇关于Azure的EF code首先迁移初始化器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆