4

I'm currently trying to write a unit / integration test using Effort as an in memory database provider.

I've been following the tutorial for creating a fake DbContext instance however I'm getting a System.ArgumentException : String cannot have zero length." on the creation of the EntityConnection.

Background:

  • Using Entity Framework 6
  • Using Effort 1.0.0.0
  • Using Database First approach
  • Using EntityConnectionFactory approach to creating a fake DbContext with Effort rather than DbConnectionFactory as described by the Effort tutorial
  • My DbContext has the appropriate constructor taking a single DbConnection parameter

The connection string is defined in the app.config for the test runner and works with non-Effort based tests some of which read / write to the test database. I have removed any sensitive data:

<connectionStrings>
    <add name="MyConnectionString" 
        connectionString="metadata=res://*/;provider=System.Data.SqlClient;provider connection string='data source=localhost;initial catalog=MyDatabaseName;persist security info=True;user id=myuser;password=mypassword;MultipleActiveResultSets=True;App=EntityFramework'" 
        providerName="System.Data.EntityClient" />
</connectionStrings>

The stack trace for the error is below:

System.ArgumentException : String cannot have zero length. at System.Reflection.RuntimeAssembly.GetResource(RuntimeAssembly assembly, String resourceName, ref UInt64 length, StackCrawlMarkHandle stackMark, Boolean skipSecurityCheck) at System.Reflection.RuntimeAssembly.GetManifestResourceStream(String name, ref StackCrawlMark stackMark, Boolean skipSecurityCheck) at System.Reflection.RuntimeAssembly.GetManifestResourceStream(String name) at Effort.Internal.Common.MetadataWorkspaceHelper.ParseResources(String resPath, List1 csdl, List1 ssdl, List1 msl) at Effort.Internal.Common.MetadataWorkspaceHelper.ParseMetadata(String metadata, List1 csdl, List1 ssdl, List1 msl) at Effort.Internal.Common.MetadataWorkspaceHelper.Rewrite(String metadata, String providerInvariantName, String providerManifestToken) at Effort.EntityConnectionFactory.b__1(String metadata) at Effort.Internal.Caching.MetadataWorkspaceStore.<>c__DisplayClass1.b__0() at System.Lazy1.CreateValue() at System.Lazy1.LazyInitValue() at System.Lazy1.get_Value() at Effort.Internal.Caching.ConcurrentCache2.Get(TKey key, Func1 factory) at Effort.Internal.Caching.MetadataWorkspaceStore.GetMetadataWorkspace(String metadata, Func2 workspaceFactoryMethod) at Effort.EntityConnectionFactory.GetEffortCompatibleMetadataWorkspace(ref String entityConnectionString) at Effort.EntityConnectionFactory.CreateTransient(String entityConnectionString, IDataLoader dataLoader) at Effort.EntityConnectionFactory.CreateTransient(String entityConnectionString) at NUnitTests.EffortTests.BasicAdd() in EffortTests.cs: line 43

Does anyone have any idea what I'm doing wrong?

6
  • providerName="System.Data.EntityClient" and ;provider=System.Data.SqlClient; ? why? Commented Jun 18, 2014 at 0:41
  • Entity Framework Config File Settings - CF: Connection Strings / "EF Designer based models use special EF connection strings." Commented Jun 18, 2014 at 0:45
  • you said using some in memory provider. Looks like SQL server in the connection string. if you are sure your Config is correct forget it. Just not what i expected given the description. Commented Jun 18, 2014 at 1:02
  • I'm using EF6 in a database first manner so the EDMX is generated by looking at an SQL database. That connection string is the string that points to that database and refers to the created EDMX. Effort claims to work with database first EF6 usage and the tutorial states that I should "use the EntityConnectionFactory component and pass a connection string that refers to the EDMX file" so I just used my default connection string. I'm not sure what I'd need to cut out to get it to simply refer to the EDMX file, if that's even possible? Commented Jun 18, 2014 at 1:12
  • ok sorry... cant help with that Commented Jun 18, 2014 at 1:22

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.