8

OVERVIEW
Using Fitnesse with EF6, can't get Effort to start up. I've tried every trick in all the posts I can find.
All the posts say to either call 'RegisterProvider', or add a config section. Neither is working.

So far:
I have "Effort.Provider" in the DbProviderFactories section in machine.config. I have Effort.Provider showing up when I look at DbProviderFactories.GetFactoryClasses(); ProcMon shows that it is looking for and finding Effort.dll.

Result:
Any of

DbConnectionFactory.CreateTransient();   
Effort.EntityConnectionFactory.CreateTransient(connectionString);   
DbProviderFactory dataFactory = DbProviderFactories.GetFactory(dt.Rows[5]);   

throw

Effort.Exceptions.EffortException: The Effort library failed to register

Also tried:
"Effort.Provider" in the entityFramework section of Runner.exe.config but couldn't get that to work. Just crashed the app.
Uninstalling EF and Effort.EF6 and re-installing. No visible effect.
Calling Effort.Provider.EffortProviderConfiguration.RegisterProvider(); from a class constructor and various startup locations. Effort.Provider never showed up in DbProviderFactories.GetFactoryClasses();
With "Effort.Provider" in the DbProviderFactories section in app.config, it shows up in GetFactoryClasses just as well as machine.config.

Using:
Windows 10
.Net 4.6
VS 2016
EF 6.1.2 (although it says 6.1.3 is installed, not sure what that means)

Do I need to register a DLL or something? Nothing in the instructions about that.

More Details:
App.config

<configuration>
    <runtime>
        <loadFromRemoteSources enabled="true"/>
    </runtime>
    <system.data>
        <DbProviderFactories>
            <add name="Effort.Provider" invariant="Effort.Provider" description="Effort.Provider" type="Effort.Provider.EffortProviderFactory, Effort" />
        </DbProviderFactories>
    </system.data>
</configuration>
1
  • I thought it might be getting to the Effort factory, which appears to be Effort.Provider.EffortProviderFactory, and throwing an exception, but that doesn't appear to be the case.
    – BWhite
    May 2, 2016 at 23:16

1 Answer 1

10

It looks like you need to register the "entityFramework" config section in the app.config file.

<configSections>
   <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
 <entityFramework>
   <providers>
      <provider invariantName="Effort.Provider" type="Effort.Provider.EffortProviderServices,Effort" />
    </providers>
 </entityFramework>

Then in your code create the Effort connection and pass it to your DbContext. If you don't already have a constructor that takes an object of type System.Data.Common.DbConnection, create one.

System.Data.Common.DbConnection connection = DbConnectionFactory.CreateTransient();
var context = new MyContext(connection);

I would also recommend setting a connectionString in your app.config. I believe the call to CreateTransient creates a connection for you, but if your code under test has code that creates another dbContext somewhere, Effort will look to the app.config to get that information. Below is an example that will create a transient database so that all operations completed in one test do not affect another test.

<add name="DefaultConnection" connectionString="Data Source=in-process;IsTransient=true" providerName="Effort.Provider" />
4
  • The defaultConnection part is the only part I don't have. I'll try that. I didn't look too hard in that direction because I assumed that would give a different error , not stop the class from being created. In fact I write to the console in the constructor. I have every reason to believe the error. It just can't find it. Even though procmon shows it reading the effort library.
    – BWhite
    May 15, 2016 at 13:59
  • I have this same problem, but this answer does not solve it. Any other ideas?
    – Jess
    Feb 16, 2017 at 0:47
  • 1
    The only other thing I can think of is to make sure that you have the following section as a child element of the <configuration> element in your app.config <system.data> <DbProviderFactories> <add name="Effort Provider" description="Effort in memory db provider" invariant="Effort.Provider" type="Effort.Provider.EffortProviderFactory,Effort" /> </DbProviderFactories> </system.data> Make sure the invariant matches the invariantName in the EF providers section Feb 17, 2017 at 14:03
  • Thanks for providing the key piece of the puzzle I was missing Bobby - the original article describing how to get this working omits the connection string.
    – mattpm
    Aug 24, 2017 at 2:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.