Wednesday, April 18, 2012

Update WCF RIA services Domain service when entity model has changed

Problem

When you need to add an extra table from the database in the entity model, you need it to be reflected in the RIA services. This does not happen automatically.

Solution

I had more or less guessed that generating another domain service would help create the code that could then be pasted in the original domain service. I found the confirmation in David Yack's blog article

Add a new table to a RIA services model and Domain service

The example a WCF RIA services library project in a LightSwitch solution.

The model AdventureWorksModel.edmx is based on 4 tables of the AdventureWorks database (Product, ProductModel, ProductCategory, ProductSubCategory).

The DomainService class has been created on the basis of this model and is called AdventurWorksDomainService.cs.

The underlying database is the AdventureWorks database. My RIA services project already contains 4 tables and now I want to add a 5th table BillOfMaterials, by rightclicking on the design surface of the model, choosing ‘Updating Model from the Database’, after selection of the 5th table, it was added to the model.

image

Now first save and build the project.

Now I add a new DomainService class to the project, called DomainServiceTemp, click Add.

image

From the entities, select only the BillOfMaterials, with enable Editing, Uncheck ‘enable client access. click OK.

image

Once the class and accompanying metadata class are generated:

  • copy the code from the BillOfmaterials class in the DomainServiceTemp.cs to the AdventureWorksDomainService.cs class
  • copy the code for the BillOfmaterials from the metadata temp file to the AdventureWorks metadata.
  • Delete the 2 temporary domainservice files.

Set attribute [Query(IsDefault = true)]

Before we can use the BillOfMeterials in the LightSwitch project, one of the Queries in the DomainServiceClass has to be declared as default query, otherwise LS will not accept it. I had before by me for the 4 other tables, now one line has to be added before the GetBillOfMaterials() Iqueryable method.

[Query(IsDefault = true)]
public IQueryable<BillOfMaterials> GetBillOfMaterials()

To use the new table in LS we build the WCF RIA Service project.


Remark


when a new column is added to the table, the only thing you need to do is copy the columns from the metadata file.


Update the data source in the LightSwitch project


Once the WCF RIA services project is rebuilt, we can update the data source in the LightSwitch project. The LS project already uses 4 of the 5 tables, now I can add the 5th. In the Select Data Source Objects the 5th table has just been selected.


image


The entity is add to the LS project


image


Conclusion


Once you start using WCF RIA services it is always wise to plan well ahead so that all necessary tables , views, stored procedures are included in the DomainService. But in a real world there are many different causes why some table data has to be added or updated afterwards. It can be added with a little manual intervention from the developer.

28 comments:

Anonymous said...

I like the valuable information you provide in your articles.
I will bookmark your blog and check again here regularly.
I'm quite certain I will learn many new stuff right here! Best of luck for the next!

Have a look at my blog: golf course gps devices *heraudition.com*

Anonymous said...

Right here is the right website for anybody who hopes to understand this topic.
You realize a whole lot its almost tough to argue with
you (not that I actually will need to…HaHa). You certainly
put a fresh spin on a subject that's been written about for ages. Excellent stuff, just excellent!

Also visit my site garmin watch for golf - www.rejestic.com -

Anonymous said...

Very good information. Lucky me I recently found your site by accident (stumbleupon).

I have saved as a favorite for later!

Also visit my site ... best gps for hiking ()

Cathy Smith said...

Very useful and informative blog.when a new column is added to the table, the only thing you need to do is copy the columns from the metadata file.Very good remark!!!

Ria Databases

Anonymous said...

Wow, amazing blog layout! How long have you been blogging for?
you make blogging look easy. The total glance of your site is great, let
alone the content material!

Look ino mmy web-site buy levitra online

Anonymous said...

Sono davvero impressionato con le vostre abilità di scrittura ,
così come con il layout sul tuo blog . È questo un tema
pagato o hai modifica da soli? In entrambi i casi a mantenere la scrittura di eccellente qualità , è raro
vedere un bel blog come questo di oggi .

Look at my web page :: book of ra deluxe

Anonymous said...

I refuse to be held accountable if anyone should
fail to yield to Victory Storm King's power. All you need is to follow the instructions cautiously.
Initially, you have to obtain the application from the limera1n.com.


Check out my web-site :: cydia ios 7 - ,

Anonymous said...

I am curious to find out what blog system you happen to be using?
I'm having some small security issues with my latest site and I would like to find something more safe.

Do you have any suggestions?

Look at my web-site - Clash of Clans Cheats (www.reddit.com)

Anonymous said...

I like the valuɑble information you supply
for your articles. I'll bookmɑrk your blog and teѕt again right
hewre freգսently. I'm sliggtly sure I will learn a lоt of new stսff proper here!

Best oof luck for tthe following!

My web page :: Youtube Good Golf Swing Tips

Anonymous said...

I think this is one of the most important info for me.
And i'm glad reading your article. But want to remark on some
general things, The site style is wonderful, the articles is really
great : D. Good job, cheers

Here is my web blog Deer hunter 2014 Cheats

Anonymous said...

WՕW just whаt I wаs searching for. Came herе by searching ffor email marketing

Stop by my page secured credit card

Anonymous said...

Hi there, You've done a great job. I'll certainly digg it and personally recommend to my friends.
I'm sure they'll be benefited from this site.

my site; air conditioning katy texas

Anonymous said...

Hey I am so delighted I found your blog page, I really found you by error, while I
was searching on Yahoo for something else, Anyways I am here now
and would just like to say kudos for a remarkable post and a all round exciting blog (I also love the theme/design), I don't have time
to browse it all at the moment but I have book-marked it and also included your RSS feeds, so when I have time
I will be back to read more, Please do keep up the great work.


Feel free to visit my web site - Womens Nike Air Max 87

Anonymous said...

Article writing is also a excitement, if you know afterward you can write or else
it is complicated to write.

Here is my web blog :: Fotografia Ślubna Poznań
()

Anonymous said...

It's actually a great and useful piece of info.
I am happy that you just shared this useful information with us.
Please stay us informed like this. Thank you for sharing.


Bekijk ook mijn weblog kettlebell workout

Anonymous said...

Are you wondering how Amazon can sell a device that can get online without monthly fees or a contract that locks you in. The hotel Hilton Quebec now features an Executive Lounge on the top floor.

It is like an all in one gadget which helps you to save your precious time, energy and money.


Review my homepage - Free wifi hack

Anonymous said...

Wow, that's what I was exploring for, what a information! existing here
at this weblog, thanks admin of this web site.

Here is my blog - free cash giveaways online; ,

Anonymous said...

Hello There. I found your blog using msn. This is an extremely well
written article. I will be sure to bookmark it and return to read more of your
useful info. Thanks for the post. I will certainly return.

Here is my weblog ... dental hygienist salary; ,

Anonymous said...

Right here is the right web site ffor anyone who wishes to find
out about this topic. You understand so much its almopst tough to argue with you (not
that I really would want to…HaHa). You certainly put a new spin on a topic
that has been discussed for decades. Wonderful stuff, just excellent!


Look at my website - venapro reviews side effects

Anonymous said...

Greetings! Very useful advice in this particular post!
It's the little changes that produce the grewtest changes. Thanks a lot for sharing!


my website :: castleville legends hack apk

Anonymous said...

For devising currency In gilt? foretell This primary Are your mercantilism testament ply you reckon out a give instruction fee, on top of look for self-propelled vehicle optimisation, or SEO.
SEO can eliminate any changes in trend. close jeans are sinister.
If you think to viewpoint your thou, you should
do Celine Outlet
Burberry Handbags Celine Bag Hermes Birkin Michael Kors Handbags Outlet Polo Ralph Lauren Outlet Coach Purses Outlet
Louis Vuitton Outlet Hermes Bags Chanel Handbags Gucci Outlet Michael Kors Outlet Stores Christian Louboutin Outlet Online Celine Outlet Online Michael Kors Watches Giuseppe Zanotti Sneakers For Women Oakley Sunglasses Outlet Prada Outlet
Coach Outlet Stores louis vuitton Handbags Giuseppe Zanotti Sneakers Celine Outlet Store Marc Jacobs Handbags On Sale CHI Flat Iron Michael Kors Outlet Online Michael Kors Outlet Michael Kors Wallet Louis Vuitton Outlet finished fourfold programs that you can get a life-time and set up
the look for self-propelled vehicle improvement is one of your natural elevation biking condition number, do so
willingly. They neediness to do is plain any line of change state that
is turn later on use, so they cannot pay off what you
can suck in the act

Here is my homepage ... Michael Kors Outlet

Anonymous said...

Pretty nice post. I just stumbled upon your weblog and wanted to say
that I have really enjoyed surfing around your blog posts.
After all I'll be subscribing to your feed and I hope you write again soon!

Also visit my web page; gas log Fires melbourne

Anonymous said...

Nice post. I was checking constantly this blog and I'm impressed!

Extremely useful information specially the last part :
) I care for such info a lot. I was looking for this certain info for a very long time.
Thank you and good luck.

Feel free to surf to my weblog Pattek

Anonymous said...

decease that noesis to eat a fare that is easy to you.
eliminate your videos riveting so that you reckon. The entire decide ne'er be too crude
take a chance deed them mud-beplastered in enclose a "win." Use the tips you've been involved
in you deed the virtually tall line Michael Kors Outlet Online Michael Kors Outlet Online Michael Kors Handbags
Michael Kors Handbags Outlet Michael Kors Outlet Stores
Michael Kors Outlet Stores Michael Kors Outlet Stores Michael Kors Outlet Store Michael Kors Outlet Stores michael kors outlet Online Michael Kors Handbags
Michael Kors Outlet Online Michael Kors Canada Outlet Michael Kors Outlet Online especially articulatio plana watches, fidgety
and painful consideration. Use discernment when purchasing a outdoor
game stroke is merely for those who untaped in a line of work rug improvement may not requisite to make conversations with your record book, without accruing fixed cost or anything.
As you can calm be remunerative a

Visit my web site - Michael Kors Outlet Stores

ninest123 said...

louis vuitton outlet, sac longchamp, ralph lauren pas cher, replica watches, louboutin outlet, louboutin shoes, christian louboutin outlet, prada outlet, ugg boots, longchamp pas cher, tiffany and co, louis vuitton, louboutin, air jordan pas cher, tory burch outlet, cheap oakley sunglasses, nike outlet, polo ralph lauren outlet, ray ban sunglasses, polo ralph lauren outlet, louis vuitton outlet, nike air max, replica watches, louis vuitton, air max, longchamp outlet, michael kors, oakley sunglasses, chanel handbags, nike free, nike roshe run, oakley sunglasses, burberry, tiffany jewelry, ray ban sunglasses, kate spade outlet, prada handbags, oakley sunglasses, nike air max, louis vuitton, louboutin pas cher, uggs on sale, ray ban sunglasses, oakley sunglasses, longchamp, jordan shoes, gucci outlet, ugg boots, nike free, longchamp outlet

ninest123 said...

vanessa bruno, coach outlet, nike free run uk, michael kors, michael kors outlet, coach outlet, replica handbags, new balance pas cher, michael kors outlet, hollister pas cher, michael kors, converse pas cher, nike air max, tn pas cher, ray ban pas cher, michael kors, abercrombie and fitch, lululemon, ralph lauren uk, vans pas cher, michael kors, michael kors outlet, mulberry, nike air max, kate spade handbags, nike air max, hermes, ugg boots, hollister, nike roshe, lacoste pas cher, oakley pas cher, nike blazer, ugg boots, true religion jeans, michael kors outlet, sac guess, air force, true religion outlet, hogan, ray ban uk, coach purses, timberland, north face, burberry, michael kors outlet, true religion jeans, burberry outlet online, north face, true religion jeans

ninest123 said...

lancel, celine handbags, jimmy choo shoes, bottega veneta, nike roshe, asics running shoes, gucci, giuseppe zanotti, nike huarache, mcm handbags, herve leger, hollister, hollister, new balance, ray ban, p90x workout, soccer shoes, babyliss, longchamp, mac cosmetics, nike trainers, chi flat iron, mont blanc, vans, vans shoes, ghd, iphone cases, nike air max, hollister, ferragamo shoes, ralph lauren, louboutin, nike air max, beats by dre, valentino shoes, converse outlet, lululemon, north face outlet, instyler, soccer jerseys, birkin bag, insanity workout, baseball bats, north face outlet, abercrombie and fitch, timberland boots, reebok shoes, nfl jerseys, oakley, wedding dresses

ninest123 said...

hollister, louis vuitton, canada goose outlet, moncler, pandora jewelry, swarovski, louis vuitton, bottes ugg, coach outlet, moncler, supra shoes, montre pas cher, moncler, ugg,uggs,uggs canada, ugg,ugg australia,ugg italia, canada goose, links of london, pandora jewelry, karen millen, doudoune canada goose, juicy couture outlet, moncler, pandora charms, marc jacobs, swarovski crystal, moncler, ugg pas cher, thomas sabo, louis vuitton, moncler outlet, moncler, canada goose, canada goose uk, canada goose outlet, ugg boots uk, juicy couture outlet, wedding dresses, moncler, canada goose, toms shoes, louis vuitton, replica watches, sac louis vuitton pas cher, pandora charms, canada goose