如何将Azure数据库与WCF服务一起使用?

时间:2015-07-27 06:37:40

标签: entity-framework wcf azure ef-code-first

我创建了一个使用WCFServiceWebRole从Azure成功运行的WCF服务。现在我希望WCF服务的代码使用应该使用Entity Framework Code First创建的数据库。我在一个单独的项目中创建了实体和上下文。我可以使用像这样的app.config(非常标准)从本地测试项目创建和使用数据库:

 <connectionStrings>
    <add name="MyContext" connectionString="Data Source=(LocalDb)\MSSQLLocalDB;Initial Catalog=MyLocalDb;MultipleActiveResultSets=True;Integrated Security=True;AttachDBFilename=|DataDirectory|MyLocalDbFile.mdf" 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>

但现在我面临将代码部署到Azure的挑战。我使用NuGet将EntityFramework添加到WCFServiceWebRole项目,但是web.config没有像app.config那样被改变。我在Azure上租了一个数据库,我可以使用SQL Server对象资源管理器连接到它。但它结束了。

当我查看WCF项目的上下文菜单时,我可以选择“发布到Microsoft Azure”(用于部署WCF服务,但不执行任何其他操作)和“发布...”后者应该给出部署数据库(Example)的选项,但向导找不到数据库。

这是否有noob指南?我的谷歌技能让我失望......

0 个答案:

没有答案
相关问题