New Posts New Posts RSS Feed: EntityServerException
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

EntityServerException

 Post Reply Post Reply
Author
danielg View Drop Down
Newbie
Newbie


Joined: 24-Apr-2008
Location: Canada
Posts: 6
Post Options Post Options   Quote danielg Quote  Post ReplyReply Direct Link To This Post Topic: EntityServerException
    Posted: 08-May-2008 at 5:04pm
I'm quite new to the EF Beta and I am having a few issues getting things to work properly. The install went great, mapping went fairly well, but whenever I try to start my application and pull data I get this error...

Error in EdmKey CustomDB: Unable to locate an ObjectContext in the probe assemblies.  This is often caused by not copying your EF model 'dll' to the deployment directory.

-------- Stack Trace ------------

"   at IdeaBlade.EntityModel.v4.EntityManager.HandleEntityServerException(Exception pException, Boolean pTryToHandle, PersistenceOperation pOperation)\r\n   at IdeaBlade.EntityModel.v4.EntityManager.ExecuteServerQuery(IEntityQuery pEntityQuery)\r\n   at IdeaBlade.EntityModel.v4.EntityManager.ExecuteFetch(IEntityFinder finder)\r\n   at IdeaBlade.EntityModel.v4.EntityQueryFinder.Execute()\r\n   at IdeaBlade.EntityModel.v4.EntityManager.ExecuteQueryCore(IEntityQuery query, QueryStrategy strategy)\r\n   at IdeaBlade.EntityModel.v4.EntityManager.ExecuteQuery[T](IEntityQuery query, QueryStrategy strategy, Boolean checkT)\r\n   at IdeaBlade.EntityModel.v4.EntityManager.ExecuteQuery[T](IEntityQuery`1 query)\r\n   at IdeaBlade.EntityModel.v4.EntityQuery`1.GetEnumerator()\r\n   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n   at TestUI.Form1..ctor() in D:\\Memx\\Programs\\DFManger\\TestUI\\Form1.cs:line 23\r\n   at TestUI.Program.Main() in D:\\Memx\\Programs\\DFManger\\TestUI\\Program.cs:line 18\r\n   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n   at System.Threading.ThreadHelper.ThreadStart()"

--- End of Stack Trace ---------------


I have verified that my model dll is getting copied to the output directory.  I get this same error when attempting to run any of the learning units that were included in the distribution as well. 

I am running Server 2003 x64,  VS2008 professional and I do have an older 3.6.x version of DevForce installed.

Any help would be appreciated.

Thanks, Daniel
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: 08-May-2008 at 5:55pm
Daniel,
 
You need to ensure that the "EF entity model assembly" and the associated artifact files (*.msl, *.csdl, *.ssdl) can be found at runtime, usually in the working directory.
 
DevForce EF does add a post-build event to any project referencing the "DEF domain model assembly" to copy these files, but in Beta1 that post-build happens one step too late.  If you build a second time it should successfully copy the files.
 
It's possible that the post-build event was not successfully added to your project, in which case you'll need to either write your own, or manually copy the files to the executable directory.  If a post-build was not created for you, please let us know, since that's a bug.
 
Here's a sample post-build from one of the tutorials:
 
rem [IdeaBlade-begin]
copy  "C:\Head\Learning Units\100 Fundamentals\020 Retrieving Data\02 Tutorials\CS\Completed_Pt1\ServerModelNorthwindIB\bin\Debug\*.csdl" "$(TargetDir)"
if errorlevel 1 goto BuildEventFailed
copy  "C:\Head\Learning Units\100 Fundamentals\020 Retrieving Data\02 Tutorials\CS\Completed_Pt1\ServerModelNorthwindIB\bin\Debug\*.msl" "$(TargetDir)"
if errorlevel 1 goto BuildEventFailed
copy  "C:\Head\Learning Units\100 Fundamentals\020 Retrieving Data\02 Tutorials\CS\Completed_Pt1\ServerModelNorthwindIB\bin\Debug\*.ssdl" "$(TargetDir)"
if errorlevel 1 goto BuildEventFailed
copy  "C:\Head\Learning Units\100 Fundamentals\020 Retrieving Data\02 Tutorials\CS\Completed_Pt1\ServerModelNorthwindIB\bin\Debug\ServerModelNorthwindIB.dll" "$(TargetDir)"
if errorlevel 1 goto BuildEventFailed
copy  "C:\Head\Learning Units\100 Fundamentals\020 Retrieving Data\02 Tutorials\CS\Completed_Pt1\ServerModelAw2000\bin\Debug\*.csdl" "$(TargetDir)"
if errorlevel 1 goto BuildEventFailed
copy  "C:\Head\Learning Units\100 Fundamentals\020 Retrieving Data\02 Tutorials\CS\Completed_Pt1\ServerModelAw2000\bin\Debug\*.msl" "$(TargetDir)"
if errorlevel 1 goto BuildEventFailed
copy  "C:\Head\Learning Units\100 Fundamentals\020 Retrieving Data\02 Tutorials\CS\Completed_Pt1\ServerModelAw2000\bin\Debug\*.ssdl" "$(TargetDir)"
if errorlevel 1 goto BuildEventFailed
copy  "C:\Head\Learning Units\100 Fundamentals\020 Retrieving Data\02 Tutorials\CS\Completed_Pt1\ServerModelAw2000\bin\Debug\ServerModelAw2000.dll" "$(TargetDir)"
if errorlevel 1 goto BuildEventFailed
goto BuildEventOK
:BuildEventFailed
echo IdeaBlade post-build event for $(ProjectName) failed
exit 0
:BuildEventOK
echo IdeaBlade post-build event for $(ProjectName) completed Ok
rem [IdeaBlade-end]
Back to Top
danielg View Drop Down
Newbie
Newbie


Joined: 24-Apr-2008
Location: Canada
Posts: 6
Post Options Post Options   Quote danielg Quote  Post ReplyReply Direct Link To This Post Posted: 09-May-2008 at 8:22am
Thank you for the explanation at least I now know why this is happening.  Yes the post build commands are being generated correctly.  The problem lies however in the fact that the .csdl .msl and .ssdl files are not being generated. The output directory for the EF mapping project only contains one dll. I did some searching and it appears that this is the standard behavior in EF Beta 3.  Apparently those three files are complied into the dll.

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=2108642&SiteID=1

Is this something that you have encountered before?
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: 09-May-2008 at 8:59am
EF Beta3 creates one .edmx file in your project when you add a new ADO.NET Entity Data Model.  The BuildAction for that file should be "EntityDeploy", which ensures that when the project is built the 3 metadata artifact files (*.csdl, *.msl, *.ssdl) are generated into your bin directory.  There is an option to embed these files as resources in the output DLL, but in truth that doesn't work too well right now.  In our tutorials, you should see these artifact files created in the bin directory of the "EF entity model" project folder.
 
So, double check that these files were generated, and if not, check that the BuildAction of the edmx file is correct.  And then, once generated, ensure that they are copied to your executable folder (by the post-build event). 
 
Back to Top
danielg View Drop Down
Newbie
Newbie


Joined: 24-Apr-2008
Location: Canada
Posts: 6
Post Options Post Options   Quote danielg Quote  Post ReplyReply Direct Link To This Post Posted: 09-May-2008 at 9:59am
Thanks for you help I got it figured out.  In the end it was my trying to using the Entity Framework tools on x64 when they are really only for 32bit.   The EntityDeploy MsBuild task was not getting triggered and thus the Entity Fragment files were not ending up in the output directory.  The strange thing though is that there were no errors generated so I though things were building fine.  After some searching I found an article that helps to workaround this problem on x64.

http://forums.devx.com/archive/index.php/t-165542.html

After this the build works correctly.  Thank you for your help.

Daniel
Back to Top
smiller View Drop Down
Newbie
Newbie


Joined: 14-Apr-2008
Location: United States
Posts: 16
Post Options Post Options   Quote smiller Quote  Post ReplyReply Direct Link To This Post Posted: 15-May-2008 at 9:02am
Originally posted by kimj

DevForce EF does add a post-build event to any project referencing the "DEF domain model assembly" to copy these files, but in Beta1 that post-build happens one step too late.  If you build a second time it should successfully copy the files.
 
It's possible that the post-build event was not successfully added to your project, in which case you'll need to either write your own, or manually copy the files to the executable directory.  If a post-build was not created for you, please let us know, since that's a bug.
 
Is there anyway to turn off the addition of the post-build event.  I'd much rather set "Metadata Artifact Processing" to "Embed in Output Assembly" in my EDMX model... which I believe makes the post-build steps unnecessary.
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: 15-May-2008 at 10:54am
Unfortunately there's not currently a way to turn off the post-build event.  You can, though, add some post-build event commands of your own to bypass the copy logic.  Try adding a "goto BuildEventOK" as the first line in the post-build command line, prior to the "rem [IdeaBlade-begin]" line.  The post-build command will still be executed, but this should jump to a label near the end of the processing.

You're right that using embedded artifacts makes the post-build unnecessary, but we've found in the Entity Framework Beta3 that resource embedding doesn't work well.   EF Beta4, which we're working with now and which DEF Beta2 will work with, has much improved embedded resource support.

Back to Top
smiller View Drop Down
Newbie
Newbie


Joined: 14-Apr-2008
Location: United States
Posts: 16
Post Options Post Options   Quote smiller Quote  Post ReplyReply Direct Link To This Post Posted: 16-May-2008 at 7:16am
Adding some script to the begging/end of the post build event is a reasonable workaround.  Can I suggest that there be an option in future version of DEF to turn this off however?  Or better yet, automagically figure out if I've turned on "Embed in Output Assembly" and simply leave the post build actions out?
 
It appears that with EF Beta 3 each time I change my Model I have to build once with "Metadata Artifact Processing" set to "Copy to Output Directory" before I can build with the "Embed in Output Assembly" option.  Not that there's not a build failure... but without the extra step any changes I've made aren't persisted leaving me with a stale assembly.
 
Haven't tried this with EF Beta 4, but after reading the breaking changes (http://blogs.msdn.com/adonet/pages/entity-framework-breaking-changes-visual-studio-2008-net-3-5-sp1-beta.aspx) I can only assume that DEF Beta 1 isn't going to work with it.  Understandable.  Any idea on the timeframe for DEF Beta 2?
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: 16-May-2008 at 9:13am
DEF Beta2 will have an option to turn off the post-build event.  DEF Beta2 is built on top of the new .NET 3.5 SP1 Beta (aka EF beta4) and is .. coming soon.  I've been proved wrong about this before, but we should be going to final internal testing next week.  DEF Beta1 does not work with the new EF bits.
 
The problem you're seeing with having to switch the metadata artifact processing back and forth between embedded and output files actually has nothing to do with DevForce; it's a limitation in EF beta3, and why we recommend against using the embedded option with it.  EF beta4 does not have this problem.
 
Back to Top
smiller View Drop Down
Newbie
Newbie


Joined: 14-Apr-2008
Location: United States
Posts: 16
Post Options Post Options   Quote smiller Quote  Post ReplyReply Direct Link To This Post Posted: 19-Jun-2008 at 1:52pm
The "Generate post-build event" option in DEF RC1 is a welcome addition.  My only suggestion is that maybe this option shouldn't exist at all, and could simply follow what the EF Model's metadata artifact processing property is set to.
 
Either way, I like that I now have the ability to get rid of the post build event.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down