none
Getting data from Database view to UI useing Entity Framework RRS feed

  • Question

  • Hi Friends,

    I am new to EF. Please help me to understand this one.  I have database with  some views. I want to add this views to my edmx and want to  query get data into UI  application. So  is there are any limitation here..  how can I do this one.. 

    Please provide some info , any good tutorial on this..

     

    ~Priya

     

     

     

     

    Sunday, July 17, 2011 5:47 AM

Answers

  • Hi Priya,

    The article given by Syed more or less can explain your question about primary key. In that article, you can find many "The key has been inferred and the definition was created as a read-only table/view." It said that, if we don't have a primary key for one object, it would be read-only. Namely, with primary key, we can insert a new object, update an object, select an object and delete one.

    By default, Entity Framework will do search the Objects through their primary keys. I hope this can help you.

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, July 18, 2011 6:31 AM
    Moderator

All replies

  • In EF designer you will be prompted first for a connection string.

    Point it to the database with appropriated userid/password.

    Then it will show all the tables, click on the ones you want and check the checkbox (if you want) to enable editing. 

    From there you can access everything as an object after you have new'd up an instance of the Entity  e.g. DBEntities dbent = new DBEntities...   From there you simple run a query or update on a class basis.

    Just search google for Entity Framework 4.0 Examples.


    JP
    Sunday, July 17, 2011 6:56 AM
  • Hi,

    If you want your view to be updateable, then you might want to have a look at this post: Entity Framework: Creating a model using views instead of tables

    Regards,


    Syed Mehroz Alam
    My Blog | My Articles
    Sunday, July 17, 2011 12:09 PM
  • Why it is mandatory for every object in Database should  have primary key .. so that it can be added to edmx. ?
    Sunday, July 17, 2011 6:30 PM
  • Hi Priya,

    The article given by Syed more or less can explain your question about primary key. In that article, you can find many "The key has been inferred and the definition was created as a read-only table/view." It said that, if we don't have a primary key for one object, it would be read-only. Namely, with primary key, we can insert a new object, update an object, select an object and delete one.

    By default, Entity Framework will do search the Objects through their primary keys. I hope this can help you.

     

    Have a nice day,


    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, July 18, 2011 6:31 AM
    Moderator