none
SQLCE Views and EntityFramework RRS feed

  • Question

  • Hi,

    I am using SQLCE4 with the Entity Framework and I know SQLCE does not support Views.  I have a small database which has some relational mappings between it.

    What I would like to do is be able to write some Views in Code so that my application can read the data from the Entity Model without having to create some custom types to transform the data into.

    Think of a two tables with an FK between them.  I have a core table and want to to have a view that might have a column that says IsRelated (where the determine for this field - a bit - might be if it has a value in the other table).

    Can I create my own views in the entity framework in Code?  Or should I pre-create them in the edmx file and than fill them with data at runtime?

    Thanks - Greg.

    Tuesday, May 8, 2012 2:35 PM

Answers

  • Hi Greg_AD,

    Welcome to MSDN Forum.

    Yes, add a defining query and a corresponding conceptual entity type to an .edmx file. A defining query allows you to execute an SQL statement that is specified in the DefiningQuery element of an .edmx file. A defining query is commonly used to provide functionality similar to that provided by a database view, but the view is defined in the .edmx file, not the database. Please refer the link below for more information. This document introduces how to add a definining query, and there's a good demo in it.

    How to: Add a Defining Query (Entity Framework)

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, May 9, 2012 6:12 AM
    Moderator

All replies

  • Hi Greg_AD,

    Welcome to MSDN Forum.

    Yes, add a defining query and a corresponding conceptual entity type to an .edmx file. A defining query allows you to execute an SQL statement that is specified in the DefiningQuery element of an .edmx file. A defining query is commonly used to provide functionality similar to that provided by a database view, but the view is defined in the .edmx file, not the database. Please refer the link below for more information. This document introduces how to add a definining query, and there's a good demo in it.

    How to: Add a Defining Query (Entity Framework)

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Wednesday, May 9, 2012 6:12 AM
    Moderator
  • Thanks Allen.

    Wednesday, May 9, 2012 4:41 PM