Click here to Skip to main content
15,886,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created an outlook addin that uses a sqlite db and the entity framework, the application works 100% when running in debug with visual studio. I have then built a wix installer to install the addin which installs the addin without any problems, my issue is that when i try write to the sqlite db using the installed version i get the following error:

No connection string named 'TaskMonsterDBEntities' could be found in the application config file.

System.InvalidOperationException: No connection string named 'TaskMonsterDBEntities' could be found in the application config file.

   at System.Data.Entity.Internal.LazyInternalConnection.get_ConnectionHasModel()

   at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()

   at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)

   at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()

   at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()

   at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()

   at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)

   at TaskMonsterOutlookAddin.OutlookRibbon.RefreshLocalClientTable(List`1& clients)

   at TaskMonsterOutlookAddin.OutlookRibbon.RefreshLocal()


i suspect my connection string in my app config is not correct, could anyone suggest what the problem is or a solution? my app.config looks like this:
XML
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
    <providers>
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
      <provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
    </providers>
  </entityFramework>
  <system.data>
    <DbProviderFactories>
      <remove invariant="System.Data.SQLite"/>
      <add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" />
      <remove invariant="System.Data.SQLite.EF6" />
      <add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
    </DbProviderFactories>
  </system.data>

  <!-- For Testing  
<connectionStrings>
    <add name="TaskMonsterDBEntities" 
      connectionString="metadata=res://*/EFModel.TMModel.csdl|res://*/EFModel.TMModel.ssdl|res://*/EFModel.TMModel.msl;provider=System.Data.SQLite.EF6;provider connection string='data source=&quot;C:\Users\brighton\Documents\Visual Studio 2013\Projects\TaskMonsterOutlookAddin\TaskMonsterWPF\SQLite\TaskMonsterDB&quot;'"
      providerName="System.Data.EntityClient" />
  </connectionStrings>
  -->

  <!-- For Deployment -->
  <connectionStrings>
    <add name="TaskMonsterDBEntities"
    connectionString="metadata=res://*/EFModel.TMModel.csdl|res://*/EFModel.TMModel.ssdl|res://*/EFModel.TMModel.msl;provider=System.Data.SQLite.EF6;provider connection string='data source=&quot;C:\Program Files (x86)\Task Monster\TaskMonsterDB&quot;'"
    providerName="System.Data.EntityClient" />
  </connectionStrings>

</configuration>
Posted
Updated 9-Jul-15 23:24pm
v5
Comments
Andy Lanng 12-Jun-15 7:46am    
no one is going to access dropbox links.

just post the error in the question
Member 11761199 12-Jun-15 8:01am    
Hi Andy, how do i put images into questions?
Andy Lanng 12-Jun-15 8:09am    
people usually use tinypic.com

Can't you get the text of the error and post that?
Member 11761199 10-Jul-15 7:26am    
Hi Andy

it's a bit late but ive added the error to the question.

thanks
Andy Lanng 10-Jul-15 7:59am    
Ok - cool.
The syntax looks fine. It must be that the app is not looking at that config file. Is it being loaded as a reference in another assembly?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900