CUD Mapping for a view

3 posts, 1 answers
  1. Marco
    Marco avatar
    11 posts
    Member since:
    Jan 2014

    Posted 08 Jul Link to this post


    I defined an update stored procedure mapping for a view in the mapping details editor.

    The new defined stored procedure appears in the model schema explorer.

    In a next step i open the 'update database from model ..' form. Then i choose the migrate option .. click next ...

    now I check the generated script ...... but the new defined stored procedure doesn't appear in the sql script block....

    so that means that I can't generate the procedure on my SQL Server.

    What I'm doing wrong  .... any ideas?

    Thanks for helping..


  2. Answer
    Viktor Zhivkov
    Viktor Zhivkov avatar
    290 posts

    Posted 15 Jul Link to this post

    Hello Marco,

    In general our recommendation is to use mapped views only for read-only operations. Allowing Create, Update and Delete operations over a view is tricky as behavior largely depends on the view definition. 
    The issue that is preventing you from getting your Update procedure in the DDL scripts is cause by two facts:
    1. Telerik Data Access Runtime does not support CUD operations for Views
    2. Visual Designer does not distinguish between tables and views so it allows you to apply an unsupported feature to your view.

    Please excuse us for the confusion.
    I would suggest two different approaches to work around this limitation
    1. Use the view as read-only data source and persist any changes via dedicated persistent types bound to tables.
    2. Create the required stored procedure manually and add it to your model from the database. Call it manually whenever you want to modify a record in the view. Do not forget to commit the transaction for the procedure call by calling context.SaveChanges().

    If you need any further assistance, please let us know.

    Viktor Zhivkov
    Telerik by Progress
    Check out the latest announcement about Telerik Data Access vNext as a powerful framework able to solve core development problems.
  3. DevCraft banner
  4. Marco
    Marco avatar
    11 posts
    Member since:
    Jan 2014

    Posted 15 Jul in reply to Viktor Zhivkov Link to this post

    Thanks four Your answer.

    I found another way to realize my needed behaviour.

    I defined an insteadof trigger for the mention view. So I implemented the logic sql server side.



Back to Top