This project has moved and is read-only. For the latest updates, please go here.

Needs connection string!?

Sep 11, 2014 at 7:40 PM
I must be missing something. I've followed the basic instructions to install Effort and when running in my unit test I'm creating the transient DBConnection and passing that into an overloaded constructor in my normal context.

Our normal constructor in our context uses a connection string.

In my unit test project I don't have the connection string in the app.config and would not have thought it would need it since the context is being created with a DBConnection passed in.

All of this starts to work but the moment I to test an add data routine in my repository I get exceptions that the connection string cannot be found in the app.config.

What am I missing? In reading about this project and also posts on CodePlex it seems like I could use my standard, normal context which my app constructs as:

myContext = new appContext()

(names changes). This constructor be default calls base("connection string...")

When attempting to run unit tests I'm constructing the context as:

myContext = new appContext(DBConnection)

and I have a constructor that accepts that and passes it to base. It appears to construct ok but my first unit test attempt to add data to the context and it dies right there with an exception that the connection string (normally used in the default constructor base call) cannot be found in the app.config.


I then decided ok, I'll put it in the app.config. This causes it to get further but now I get a missing method exception:

System.MissingMethodException : Method not found: 'System.Data.Entity.Migrations.Builders.TableBuilder1<!0> System.Data.Entity.Migrations.Builders.TableBuilder1.Index(System.Linq.Expressions.Expression1<System.Func2<!0,System.Object>>, System.String, Boolean, Boolean, System.Object)'.

This looks very much like it is attempting to run the migration scaffolds we have???

Anyway some help would be appreciated. We are using .net45, EF 6.1.1, NUnit
Sep 11, 2014 at 7:44 PM
Ok it seems if I add this (from the other discussion), and remove my connection string from app.config that it works:
Sep 23, 2014 at 4:49 PM
Nice to see you have solved the issue on your own. May I ask how did you found the solution?