Open RIA Services User Support MetadataWorkspace Failure / Exception: Value cannot be null Parameter name: key  Viewed 31691 time(s), 5 post(s)., 6/2/2014 6:29:17 AM - by mark.a.thompson

ColinBlair
ColinBlair 6/2/2014 2:26:16 PM

That probably means that you don't have the connection string in the server project's web.config. When you are compiling the full application the connection string is picked up from the main web site's configuration. When RIA Services is building it doesn't know where the web application is so it uses the config file from the server project itself.

This content has not been rated yet. 
1539 Reputation 130 Total posts
1
ColinBlair
ColinBlair 6/3/2014 1:21:56 PM

Renaming your classes is the easiest solution. You are probably going to run into the same problem in the rest of your code so you are better off getting the naming fixed now.

It is possible to customize the code generation to create namespace exceptions to specify you want your Task and your Monitor. I had the same problem in my system, I do GIS road inventory work and information stored about a road is termed in GIS terminology as an "Event". Since I really didn't feel like fighting C# over calling my entity Event, I changed the name to TdmEvent. I don't remember what Tdm means anymore, but at least I have made my life easier.

This content has not been rated yet. 
1539 Reputation 130 Total posts
2
mark-a-thompson
mark.a.thompson 6/2/2014 6:29:17 AM

I have a solution that I have upgraded to use OpenRia and Entity Framework 6.  I was initially getting the generic "MetadataWorkspace' error but I have since upgraded to the beta versions and I'm now getting a more detailed message.  Unfortunately, it's still so vague, I'm not sure what the issue is.  I'm guessing it's related to a dictionary somewhere but I have no clue where.  Is the Call Stack availabe somehow?

Here's the specific error I'm getting:

Failed to get the MetadataWorkspace for the DbContext type 'ZZZ.AppServer.ZZZDbContext'. Exception: Exception has been thrown by the target of an invocation. Exception: Value cannot be null.
Parameter name: key 

I'm using EF 6 Code First and the db is getting built with no issues.  Also, I can run the web site and navigate to the http://localhost:30007/ZZZ-AppServer-ZZZDbDomainService.svc service and it comes up in the web page with no errors.  Just can't build the Silverlight application.

Any ideas on how I can get more information to find out where the source of this error is?

This content has not been rated yet. 
25 Reputation 3 Total posts
3
mark-a-thompson
mark.a.thompson 6/2/2014 11:08:04 PM

Colin,

Thanks for the tip.  That got me pointed in the right direction.  I'm now able to generate the code but have run into another challenge.

I have some classes named Task and Monitor.  They happen to conflict with classes used by the new RIA in the System.Threading namespace.  So when the code gets generated, it ends up with ambiguous reference exceptions which, I can resolve, but of course, they will get lost as soon as I rebuild the project. 

The only solution I can think of is renaming my classes so there is no name clash.  Is there a more elegant solution?

This content has not been rated yet. 
25 Reputation 3 Total posts
4
mark-a-thompson
mark.a.thompson 6/3/2014 2:59:58 PM

That's what I figured.  Thanks for the assistance on both counts.

This content has not been rated yet. 
25 Reputation 3 Total posts
5