New Posts New Posts RSS Feed: EntityManagerSaveException: No CodeFirst entities were found
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EntityManagerSaveException: No CodeFirst entities were found

 Post Reply Post Reply
Author
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Topic: EntityManagerSaveException: No CodeFirst entities were found
    Posted: 15-Nov-2011 at 9:25am
In a unit test, be sure the app.config is deployed.  The debug log will tell you if it found the config or is using a "fall back".
Back to Top
Louis View Drop Down
Newbie
Newbie


Joined: 28-Sep-2010
Posts: 5
Post Options Post Options   Quote Louis Quote  Post ReplyReply Direct Link To This Post Posted: 14-Nov-2011 at 11:51pm
Thanks Kim

In case I didn't mention it explicitly before, I was getting this error through a unit test. 
 
After I created a small console test app (with the proper connection set in the app.config) and called the same method .. the query finally works.

I will refactor the unit test to set the connection there.

Thanks


Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 14-Nov-2011 at 5:56pm
Hi Louis,
 
There's nothing you need to add, but for some reason DevForce thinks your model is a Code First one, and is following that path.  Can you double check that the connection string or edmKey "EnvisionShellEntities" is in your server's config file, and that the contents of the string contain the usual "metadata=..."?
Back to Top
Louis View Drop Down
Newbie
Newbie


Joined: 28-Sep-2010
Posts: 5
Post Options Post Options   Quote Louis Quote  Post ReplyReply Direct Link To This Post Posted: 14-Nov-2011 at 2:10pm
Hello, I am receiving the same error message.
My connection string is properly set.   I had generated the model from an existing database so I was surprised to see a need for CodeFirst. Here is my stack trace.  I see it coming from CreateDbContext().  Is there possibly something I need to add to my model? 
 

IdeaBlade.EntityModel.EntityServerException: Key 'EnvisionShellEntities': Error in DbKey EnvisionShellEntities: 

No CodeFirst entities were found in assembly Decade.CIW.Connectors.Envision4.Model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null --->

System.ArgumentException: Error in DbKey EnvisionShellEntities:  No CodeFirst entities were found in assembly Decade.CIW.Connectors.Envision4.Model,

Version=1.0.0.0, Culture=neutral, PublicKeyToken=null

 

IdeaBlade.EntityModel.Edm.DbKey.get_Builder()

IdeaBlade.EntityModel.Edm.DbKey.CreateDbContext()

IdeaBlade.EntityModel.Edm.DbKey.CreateContext()

IdeaBlade.EntityModel.EntityManager.HandleEntityServerException(Exception ex, Boolean tryToHandle, PersistenceOperation operation, Boolean throwOnError)

IdeaBlade.EntityModel.EntityManager.ExecuteServerQuery(IEntityQuerySurrogate entityQuery)

IdeaBlade.EntityModel.EntityManager.ExecuteFetch(IEntityFinder finder)

IdeaBlade.EntityModel.EntityKeyFinder.ExecuteFindThenFetch()

IdeaBlade.EntityModel.EntityKeyFinder.Execute()

IdeaBlade.EntityModel.EntityManager.ExecuteQueryCore(IEntityQuery query, Boolean isAsync)

IdeaBlade.EntityModel.EntityManager.ExecuteQuery(IEntityQuery query)

Decade.CIW.Connectors.Envision4.EnvisionClassicEntity.GetAgencyInformation() in C:\Decade Software\Corsair\Applications\CERSIntegrationWizard\Decade.CIW.Connectors.Envision4\EnvisionClassicEntityRead.cs: line 26

Decade.CIW.Connectors.Envision4.Tests.EnvisionClassicEntityReadTest.GetAgencyInformation_WhenCalled_ReturnsResult() in C:\Decade Software\Corsair\Applications\CERSIntegrationWizard\Decade.CIW.Connectors.Envision4.Tests\EnvisionClassicEntityReadTest.cs: line 77

Back to Top
Engo View Drop Down
Newbie
Newbie


Joined: 20-Sep-2011
Posts: 6
Post Options Post Options   Quote Engo Quote  Post ReplyReply Direct Link To This Post Posted: 21-Sep-2011 at 10:37am
Thanks for your answer. The problem was that I renamed the connection string but did not copy that renamed value into the server config.
Back to Top
sbelini View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 13-Aug-2010
Location: Oakland
Posts: 786
Post Options Post Options   Quote sbelini Quote  Post ReplyReply Direct Link To This Post Posted: 21-Sep-2011 at 6:45am
Hi Engo,

It looks like you are missing the connectionString in your App.config/Web.config file.

Sorry the error message is not very clear. The message will be more informational on DevForce 6.1.3.

Regards,
   Silvio.
Back to Top
Engo View Drop Down
Newbie
Newbie


Joined: 20-Sep-2011
Posts: 6
Post Options Post Options   Quote Engo Quote  Post ReplyReply Direct Link To This Post Posted: 21-Sep-2011 at 2:51am
I'm trying to store a single new entity which I create with the following code:

var systemUser = mgr.CreateEntity<SYSTEM_USER>();
systemUser.EntityAspect.AddToManager();
systemUser.syspasswordhash = vsPasswordHash;
systemUser.sysuser = psUsername;
systemUser.sysdomain = psDomain;
mgr.SaveChanges();

This gives me the following exception (when SaveChanges is invoked)

[IdeaBlade.EntityModel.EntityManagerSaveException] {"Key 'FortressManager': Error in DbKey EntityManager:  No CodeFirst entities were found in assembly model, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"} IdeaBlade.EntityModel.EntityManagerSaveException


Maybe someone can help me here, because I did not use any code first functionality (just generated the model from the database).

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down