Update .NET RIA Services Domain Service from Model
You might start looking for this option if your working with .NET RIA Services and make a change to your underlying data model and want to reflect it in your .NET RIA Services Domain Service. This option doesn’t exist but you can accommodate for it not being there with a slight work around.
Using my example, I just added a table X to my database. I then went to my Entity Framework model and did a “Update Module From Database” and selected my new table to add it to the model. At this point the most important thing to do before worrying about .NET RIA Services is to save and build your project. If you fail to do this its likely that when the .NET RIA Services wizard runs it won’t see the change yet.
Next, assuming we already have a Domain Service created let’s call it “MyDomainService" for our example. You can’t simply right click and say “Update Domain Service and have it see the new Table X we just added. So the simplest way right now to handle that is to create a new temporary domain service – let’s call it “MyDomainServiceTemp”. When you see the selection of entities select only the new Table X you just added. If you are allowing edit make that selection as well as indicate if you want metadata. The wizard will now generate the files for the new temporary domain service. Once the code generation is completed, open up the new domain service and copy the methods from the temp file to your real MyDomainServicve file. You will need to do the same thing for the Metadata file that was generated. Once you have copied the code from both files, delete the temporary domain service files from your project and build. At this point you now have added the new Table X to your domain service.
Adding columns is easier, really the only thing you have to deal with if you add a column is to add it to the metadata buddy class.
I’ve already passed along my 2 cents that this should be a right click update model type experience, however, you too should post on the forums that you want it added as well!
Reader Comments (1)
Thank you thank you thank you. I've created a large SL3 application and I always felt the RIA domain service was quite fragile. Today I had to add a new table to the model and things blew smoke and fire. This post resolved my problems, again, thank you.