Вопрос

I playing around with the John Papa's HotTowel application. The HotTowel sample uses local codecamper.sdf database and I am trying to configure it to use the database on a sql server 2008 r2. When I run the application, I am getting an error saying "An exception of type 'System.InvalidOperationException' occurred in Breeze.ContextProvider.EF6.dll but was not handled in user code." The error is occurring in the CodeCamperRepository.cs on the line that says "get {return _contextProvider.Metadata()" code. The inner exception says

The connection string 'CodeCamper' in the application's configuration file does not contain the required providerName attribute." 

I have the following code in web.config, but I unsure if it is correct:

<configuration>
      <configSections>
            <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
       </configSections>
       <connectionStrings>
          <add name="CodeCamper" connectionString="Data Source=testdb\cmstest; Integrated Security=True; MultipleActiveResultSets=True" />
      </connectionStrings>
      <system.web>
          <compilation debug="true" targetFramework="4.5" />
          <httpRuntime targetFramework="4.5" />
      </system.web>
      <entityFramework>
          <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
            <parameters>
               <parameter value="Data Source=testdb\cmstest; Integrated Security=True; MultipleActiveResultSets=True" />
            </parameters>
        </defaultConnectionFactory>
          <providers>
             <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
        </providers>
        </entityFramework>
        <system.webServer>
          <handlers>
              <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
              <remove name="OPTIONSVerbHandler" />
              <remove name="TRACEVerbHandler" />
              <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
          </handlers>
        </system.webServer>
      </configuration>

Are there any other changes I should look at to make HotTowel connect to Sql Server? what is it that breeze doesn't like about the configuration? Appreciate any insight.

thanks Community np

Это было полезно?

Решение

Just like the inner exception says: you need the providerName attribute. So change your ConnectionStrings section to:

<connectionStrings>
    <add name="CodeCamper" connectionString="Data Source=testdb\cmstest; Integrated Security=True; MultipleActiveResultSets=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

Другие советы

Just checking, but do you have the CodeCamper connection reference in your DbContext contstructor?

public CCDbContext()
        : base("CodeCamper"){ }
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top