Define a Database View from DotConnect

Define a Database View from DotConnect

Postby jongleur » Fri 19 Dec 2014 14:47

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
jongleur
 
Posts: 17
Joined: Thu 11 Dec 2014 09:42

Re: Define a Database View from DotConnect

Postby Shalex » Mon 22 Dec 2014 15:44

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.
Shalex
Devart Team
 
Posts: 7542
Joined: Thu 14 Aug 2008 12:44

Re: Define a Database View from DotConnect

Postby jongleur » Tue 23 Dec 2014 07:38

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
jongleur
 
Posts: 17
Joined: Thu 11 Dec 2014 09:42

Re: Define a Database View from DotConnect

Postby jongleur » Tue 23 Dec 2014 08:40

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.
jongleur
 
Posts: 17
Joined: Thu 11 Dec 2014 09:42

Re: Define a Database View from DotConnect

Postby jongleur » Tue 23 Dec 2014 08:51

Setting store:Type to "Views" manually does not help either.
jongleur
 
Posts: 17
Joined: Thu 11 Dec 2014 09:42

Re: Define a Database View from DotConnect

Postby Shalex » Tue 23 Dec 2014 14:12

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/38671-entity-developer.
Shalex
Devart Team
 
Posts: 7542
Joined: Thu 14 Aug 2008 12:44

Re: Define a Database View from DotConnect

Postby jongleur » Mon 05 Jan 2015 07:09

jongleur
 
Posts: 17
Joined: Thu 11 Dec 2014 09:42


Return to dotConnect for Oracle