Archive for the ‘Software Development’ Category

Code first and WCF RIA services: Failed to get the Metadataworkspace for the DbContext type ‘{Type}’

While working with WCF RIA services, DbContext (DomainContext), Entity Framework code first, and Silverlight, I received this error quite a bit whenever I tried to run or compile the Silverlight project. 

The error means that there is something wrong with your code first model.  For me, it was usually some attribute that had a wrong string it.

It is annoying because it’s almost impossible to fix this error without knowing the tricks. Good news though!  The way to get around this error is to browse to your WCF RIA service. 

1) In order to make your service browsable at all (at least consistently), you should make your project use IIS rather than IIS Express.  Go into the project settings, under the web tab, and make sure “Use Local IIS Web server” is selected and “Use IIS Express” is not selected.

2) Now you need to find the URL your domain service uses. 

2.a) Make sure “Show all files” is enabled at the top of your Solution Explorer window. 

2.b) In your Silverlight project, expand the folder “Generated_Code”.  Open the file at the root of that folder.  Search for “http://”.  You’ll find a URL that looks similar to:

http://localhost/{WcfRiaServiceProjectName}/{Domain-Service-Namespace-And-Type-Name}.svc

3) Compile the web project by itself so that you have the most up to date error showing when you browse to the URL.

4) Browse to the URL!  It should give a much better error message.  Make sure you have the web project showing exception details. If you don’t, the web page will tell you how to do so.

Are the newer generation of developers reliving past mistakes?

Though I doubt many agree, I have to say: the recent fervor behind HTML 5, CSS3, and JavaScript feels like a step in the wrong direction.

Let me explain:

I come from a time when web development made you want to cry.  I happen from a time when each browser you chose to support would require one to develop an independent set of hacked CSS rules, JavaScript, and often, HTML; and each of these browsers would require testing after each and every change.  I’ve come from a time when debugging in JavaScript meant inserting “alert” statements in dozens of places within the code and then hitting refresh in a browser.  I come from a time when large web applications would contain scores of redundant code, and scores more of unused styles and JavaScript, which would be destined to remain in the application as if they were naught but malignant tumors.

Don’t get me wrong: application development is my passion.  But doing what needed to be done to get a web application working wasn’t development… it was pre-ordained bug fixing.

But as time progressed, things became more hopeful.  XML gave us a flexible way to store data.  Then XHTML gave us a way to read web pages without concern for misinterpretation.  Then SOAP allowed us the ability to share data with others.  Then Silverlight and Moonlight gave us hope of finally ridding ourselves of the shackles that are HTML, CSS, and JavaScript, forever.  Then Windows Phone 7 arrives, promising the market share the world needs in order to take XAML seriously.  And even if you chose not to embrace XAML, you knew that the holy grail was just around the corner.

But then Apple slew Moonlight. (And I will forever curse you, Apple, for your proprietary spells have cast a gloom on us simple software folk.)

And then the masses began to talk of HTML5 as though they’d forgotten how his ancestors had ravaged our towns.

And now I can’t help but wonder, as we progress into the future: will future generations of programmers be forced to deal with the same crap that we had to deal with, over and over again?

Will the technologies used in application development prove to follow a cyclic pattern?  Clothing style does this… just think of how both the 70’s and 80’s styles have come around.  In said fashion, will one generation reintroduce hacker mentalities and force the subsequent generation to deal with the consequences?

Or will advancement be more like some technological tug-of-war between the heroic Architects and the evil Hackers… both alternately giving and then gaining ground as one seeks to build and the other seeks to destroy?

Model Driven Development and Engineering

I have some exciting news for my near future!

I have had a strong desire to develop applications using models for years and years, now.  You can call it Model-driven development (MDD) or Model-driven engineering (MDE) or model-driven architecture (MDA) or whatever you want, but I have no doubt that it is the eventual future of software engineering.

In fact, being in the business as long as I have, a lot of common development tasks become pretty mundane.  And at this point, Software architecture and MDE are the only two things I still enjoy doing.

In the past, I’ve been able to develop only small portions or even a single layer of an application from models.  However, for the last couple years, I’ve taken it upon myself to make MDE a serious pet project, and I was able to re-write a large portion of my company’s flagship product using models and then generating code from those models.  Additionally, I was able to take portions of that effort and use it to generate portions of the existing application.

So what’s the good news?  Well, in the near future, a company may be hiring me to do something similar with their product, and I think this would be most exciting task I’ve undertaken in my 18 years of software development experience!

Here’s to hoping that this project becomes a reality!