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

EF6, DB first and error Keyword not supported: 'instanceid'

Oct 31, 2013 at 11:25 AM
I'm trying to write a test using Effort.
I'm using EF6 DB first.
I installed the Effort EF6 package from nuget.
Now i get the error "Keyword not supported: 'instanceid'" when running the following code:
            var connection = Effort.DbConnectionFactory.CreateTransient();
            var context = new System.Data.Entity.DbContext(connection.ConnectionString);
            var set = context.Set<tblMitarbeiter>().ToList();
connection.ConnectionString has the value "instanceid=<SomeGUID>"
Nov 1, 2013 at 4:23 PM
Please make sure EF6 is supported by Effort. The post "" says that "Currenly there is no package published on that supports EF6, however if you downloaded Effort from the Codeplex you would find one."

Nov 1, 2013 at 5:10 PM
There is an EF6 nuget package (he probably uploaded it, after the post was made)
Nov 2, 2013 at 5:17 PM
Edited Nov 2, 2013 at 5:17 PM

Your code sample has a few errors.
var context = new System.Data.Entity.DbContext(connection.ConnectionString);
This pushes an Effort connection string to the DbContext without any EF provider specification. By default it will use the SqlClient provider (MS SQL Server) that cannot interpret an Effort Connection string. Instead of the connection string, you should pass the entire connection object.
var set = context.Set<tblMitarbeiter>().ToList();
If the previous line were implemented properly, this would also fail with the following exception:
The entity type Person is not part of the model for the current context.
You should define your own DbContext derivative class and expose the DbSets via properties.

Check the DbContext tutorial.
Nov 4, 2013 at 8:23 AM
I know, that i should wrap the Context, i just excluded it here so it is easier to understand whats going on.
I now have this code:
            var connection = Effort.DbConnectionFactory.CreateTransient();
            var econnection = Effort.EntityConnectionFactory.CreateTransient("name=FinanceDBEntities");
            var context = new System.Data.Entity.DbContext(econnection, true);
            var set = context.Set<tblMitarbeiter>().ToList();
And get the following error on the second line:
An exception of type 'System.ArgumentException' occurred in mscorlib.dll but was not handled in user code

Additional information: memberTypes

Here is my App.config:
    <!-- For more information on Entity Framework configuration, visit -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
      <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
    <add name="FinanceDBEntities" connectionString="metadata=res://*/FinanceDB.csdl|res://*/FinanceDB.ssdl|res://*/FinanceDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=<MyPCNameHere>\SQLEXPRESS;initial catalog=FinanceDB_Test;integrated security=True;asynchronous processing=True;encrypt=True;trustservercertificate=True;context connection=False;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
Nov 10, 2013 at 1:18 AM
Okey, could you provide me the stack trace of the exception?
Nov 11, 2013 at 7:37 AM
Sure, here it is:
   bei Effort.Internal.Common.TypeHelper.GetTupleType(Type[] memberTypes)
   bei Effort.Internal.DbManagement.Schema.KeyInfoHelper.CreateSelectorExpression(Type sourceType, MemberInfo[] selectorFields)
   bei Effort.Internal.DbManagement.Schema.KeyInfoHelper.CreateKeyInfo(Type entityType, MemberInfo[] properties)
   bei Effort.Internal.DbManagement.Schema.Configuration.PrimaryKeyConfiguration.Configure(EntityInfo entityInfo, DbTableInfoBuilder builder)
   bei Effort.Internal.DbManagement.Schema.Configuration.TableConfigurationGroup.Configure(EntityInfo entityInfo, DbTableInfoBuilder builder)
   bei Effort.Internal.DbManagement.Schema.DbSchemaFactory.CreateDbSchema(StoreItemCollection edmStoreSchema)
   bei Effort.Internal.DbManagement.DbContainer.<Initialize>b__0(StoreItemCollection sic)
   bei Effort.Internal.Caching.DbSchemaStore.<>c__DisplayClass1.<GetDbSchema>b__0()
   bei System.Lazy`1.CreateValue()
   bei System.Lazy`1.LazyInitValue()
   bei System.Lazy`1.get_Value()
   bei Effort.Internal.Caching.ConcurrentCache`2.Get(TKey key, Func`1 factory)
   bei Effort.Internal.Caching.DbSchemaStore.GetDbSchema(StoreItemCollection metadata, Func`2 schemaFactoryMethod)
   bei Effort.Internal.DbManagement.DbContainer.Initialize(StoreItemCollection edmStoreSchema)
   bei Effort.Provider.EffortProviderServices.DbCreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection)
   bei System.Data.Entity.Core.Common.DbProviderServices.CreateDatabase(DbConnection connection, Nullable`1 commandTimeout, StoreItemCollection storeItemCollection)
   bei System.Data.Entity.Core.Objects.ObjectContext.CreateDatabase()
   bei Effort.EntityConnectionFactory.CreateEntityConnection(MetadataWorkspace metadata, DbConnection connection)
   bei Effort.EntityConnectionFactory.CreateTransient(String entityConnectionString, IDataLoader dataLoader)
   bei Effort.EntityConnectionFactory.CreateTransient(String entityConnectionString)
   bei Senacor.UnitTests.UnitTest1.TestMitarbeiterRepositoryService() in c:\Users\pkuehn\Documents\Visual Studio 2013\Projects\Senacor\Senacor.UnitTests\UnitTest1.cs:Zeile 16.
Nov 17, 2013 at 9:24 PM
Okey, I fixed this. You surely have a large concatenated primary key.

You can download the most recent version from the nightly build repository.
Dec 20, 2013 at 2:55 PM
Today i had time to test it and it is working :)
Dec 25, 2013 at 5:34 AM
sorry, i have the same issue.
i use effort.ef6.beta5.
and i create my database code first.
it is simple.
just one table named Users
and i create a unit test something like this:
var connection = Effort.DbConnectionFactory.CreateTransient();
var context = new DbContext(connection, true);
var set = context.Set<User>().All();
Additional information: The entity type User is not part of the model for the current context.
Jan 24, 2014 at 11:49 AM
Had the same issue and Nightly build helped to resolve it. Thx a lot for nuget!
Feb 14, 2014 at 7:07 PM
I was using the EF 4-5 version and had this same problem.


What happened is I added a view to my entity framework and it had a bunch of keys. Not sure the exact number. I then limited the number of keys and the error went away.

So to fix the problem, look at your tables/views/etc in your Entity for one(s) that have a bunch of keys.

Hope this helps.