System.ArgumentException : String cannot have zero length on the creation of the EntityConnection.

Jun 18, 2014 at 4:52 PM
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:
    <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" />
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, List
1 csdl, List1 ssdl, List1 msl)
at Effort.Internal.Common.MetadataWorkspaceHelper.Rewrite(String metadata, String providerInvariantName, String providerManifestToken)
at Effort.EntityConnectionFactory.<GetEffortCompatibleMetadataWorkspace>b__1(String metadata)
at Effort.Internal.Caching.MetadataWorkspaceStore.<>c__DisplayClass1.<GetMetadataWorkspace>b__0()
at System.Lazy1.CreateValue()
at System.Lazy
1.LazyInitValue()
at System.Lazy1.get_Value()
at Effort.Internal.Caching.ConcurrentCache
2.Get(TKey key, Func1 factory)
at Effort.Internal.Caching.MetadataWorkspaceStore.GetMetadataWorkspace(String metadata, Func
2 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

Can anyone tell me what I'm doing wrong?

Thanks in advance,

Liam
Coordinator
Jun 18, 2014 at 6:08 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.