Page 1 of 1

Define a Database View from DotConnect

Posted: Fri 19 Dec 2014 14:47
by jongleur
Hi.

Is it possible to create a view similar to a defining query for an edml model (model first)?
I solved my issue here (http://forums.devart.com/posting.php?f=1&t=30948) by using a defining query and thus switching to pure model-first.

The defining query get's executed everytime I access the corresponding DBSet, which is basically the same as when using SQL Views.

In future it may be required to replace those views by materialized views, thus they have to be defined in the database.

Is that possible? If it is: How to do it?
I would like to avoid the Database First Approach now as the Model First Approach basically seems to work with the DevArt Provider without hacks.

regards
Peter

Re: Define a Database View from DotConnect

Posted: Mon 22 Dec 2014 15:44
by Shalex
jongleur wrote:In future it may be required to replace those views by materialized views, thus they have to be defined in the database.
Is that possible? If it is: How to do it?
The View Generation option of the model with Entity Framework version = Entity Framework 6 is supported for the DbContext (only with XML mapping), EntityObject, POCO, and Self-Tracking Entities templates. Just set View Generation to True and save the model.

Re: Define a Database View from DotConnect

Posted: Tue 23 Dec 2014 07:38
by jongleur
Reading what I have:
- Properties of the Model Explorers root node (Model, right click/Properties): View Generation = true, Lazy Loading Enabled = True
- "Model Settings" of that root node (right click/Model Settings), General: "View Generation" is checked, Entity Framework Version is "Entity Framework 6"
- Template used (only that one): DbContext. Adjusted Settings: Proxy Creation Enabled = False, thus (double checked) it should use XML Mapping

You say, View Generation Option is supported for
- EF 6 (check)
- for the DbContext (check)
- with XML mapping (check)
when I
- set View Generation to True and save the model (check)

but there is no view generated.

Thanks nevertheless and happy Christmas
Peter

Re: Define a Database View from DotConnect

Posted: Tue 23 Dec 2014 08:40
by jongleur
Further investigations of the issue:

- Defining the view (as "defining query") I get a correct preview result on "execute".
- "Select Data" on the Class in the model Returns a wrong result.

If I reproduce the wrapped query (which is basically SELECT * FROM ([DEFINING QUERY]) "Extent1", where * is replaced by all fields of the defining query result, and try to execute that query myself, I get an error on the field that is wrong when fetched using the model Editor.

Nevertheless: the view still isn't generated at all, the query is stored in the model and is still executed each time the DbSet is accessed via Code.

Re: Define a Database View from DotConnect

Posted: Tue 23 Dec 2014 08:51
by jongleur
Setting store:Type to "Views" manually does not help either.

Re: Define a Database View from DotConnect

Posted: Tue 23 Dec 2014 14:12
by Shalex
Looks like I misunderstood your first message in this thread.
jongleur wrote:Is it possible to create a view similar to a defining query for an edml model (model first)?
I solved my issue here (http://forums.devart.com/posting.php?f=1&t=30948) by using a defining query and thus switching to pure model-first.
The defining query get's executed everytime I access the corresponding DBSet, which is basically the same as when using SQL Views.
In future it may be required to replace those views by materialized views, thus they have to be defined in the database.
You want Entity Developer to generate a materialized view in a database basing on a defining query in the model, don't you? Please submit your request at http://devart.uservoice.com/forums/3867 ... -developer.

Re: Define a Database View from DotConnect

Posted: Mon 05 Jan 2015 07:09
by jongleur
Thanks for you help again, happy new year, and idea suggested here:

http://devart.uservoice.com/forums/3867 ... eveloper-m

regards
Peter