Entity Framework Metadata not generated
For those of you suffering with the half-baked n-tier solution that is Entity Framework and RIA Services, here’s a snippet of use. As you’ll know the metadata file is very necessary (so why is it optional?) but there’s no way you’re going to get the database design right first (or fiftieth) time so you’ll be regenerating a domain service lots.
This is a pain generally speaking but more of a pain given that you’ll have made modifications to both the DomainService class as well as the associated metadata classes. Now, those in the know will have created a buddy partial class for the DomainService so your custom queries will live there and be undisturbed by the creation of a new DomainService. However, I haven’t figured out a way to do the same for the metadata classes and these have a fair bit of custom attributes for things like validation. So when the metadata classes are regenerated there’s a cut-paste body of work to do.
And then there’s the interesting issue of your metadata classes not being re-generated with the DomainService even though you ticked the ‘Metadata’ box. You might have thought that excluding the old metadata file from the project would do the trick and well, it should. However, Visual Studio in its wisdom still ’sees’ these metadata classes – heck, you could probably delete them and it’ll still think they’re there. So the trick is to build the web project to flush out the offending old metadata classes and it works.
Of course, the burning question is why this kind of fudge is necessary? Surely, someone is supposed to test these things properly. It’s not like RIA Services and Entity Framework is fresh from the factory. Microsoft – if you’re listening – this is causing you to bleed developers. There’s, what, 80,000 working there? You can’t all be supporting IE6?