Entity Framework Core v1

Posts   
 
    
Puromtec
User
Posts: 76
Joined: 22-Jun-2005
# Posted on: 30-Oct-2017 19:20:50   

I am currently switching to use EF Core v1 and immediately ran into an issue with my existing mappings in which I have an entity mapped to a view in the database.

The designer posted the message:


"The entity 'QryOrderDetail' is mapped onto the target 'ImagineData.dbo.qryOrderDetail', which is a view. Entity Framework Core doesn't support views as mapping targets."

I am aware of this limitation in v1, and found this thread: https://github.com/aspnet/EntityFrameworkCore/issues/827

Is there a suggested path for me at this point within LLBL Gen Pro?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14982
Joined: 21-Aug-2005
# Posted on: 30-Oct-2017 23:11:01   

A workaround is to use a copy of the schema the the designer is pointed to where you have a table with the same DDL of the view. Thus tricking EF Core to have an entity, which it thinks is mapped to a table, while at runtime, it is actually mapped to a view.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 31-Oct-2017 09:47:35   

... that could be a workaround indeed, if EF Core doesn't fetch the schema at startup. I don't know if it does, but if it does, you can't work around it.

I wonder why you go for EF Core v1 tho, as EF Core v2 is available too and .net core can be installed with the app side-by-side so I'd go for that over EF Core v1 in any case (not that it solves your problem). We also released a .NET Core compatible version of our runtime btw (in v5.3, which supports .netstandard 2.0 and thus .net core 2.0) and our runtime does support views, and many more features EF Core doesn't. Besides that, it's also faster and eats less memory, win win! wink

Frans Bouma | Lead developer LLBLGen Pro
Puromtec
User
Posts: 76
Joined: 22-Jun-2005
# Posted on: 31-Oct-2017 14:58:14   

Thanks, my mistake, I need to upgrade to LLBL Gen Pro 5.3.

Puromtec
User
Posts: 76
Joined: 22-Jun-2005
# Posted on: 03-Nov-2017 22:07:32   

Walla, I actually did that to get it working.

Here is the awful set of steps.

  1. Design Views with MS SQL view designer.
  2. select into new table from view and save the ddl for the view to a file.
  3. Reverse engineer inside LLBL Gen Designer.
  4. Delete views and tables in db.
  5. Generate code.
  6. Create migration from new modelbuilder/entities.
  7. Create empty migration and add drop table statements.
  8. Create empty migration and add SQL for creating views.

Tested.

I'll try to follow what is upcoming in next version of Core v2. I'm not totally opposed to switching to LLBL Gen runtime framework, but I'm on EF for now. I like both.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 04-Nov-2017 07:56:52   

THey said they'll add View support in v2.1. It's to be seen they'll make it tho (however, to this day it's unclear to me why on earth it's impossible for them to support views in the current version, it doesn't require any work at all!) .NET core 2.1 is scheduled for q2 next year.

Frans Bouma | Lead developer LLBLGen Pro
Holger W
User
Posts: 1
Joined: 10-Sep-2018
# Posted on: 10-Sep-2018 15:05:30   

Hey guys .Net Core 2.1 is now available and Microsoft supports views. Is it now possible to use views in the Designer? I'm using version 5.4.2 and can not find support right now.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39747
Joined: 17-Aug-2003
# Posted on: 10-Sep-2018 16:15:23   

Not yet. Will come in v5.5 (currently in development). EF Core 2.1 support is implemented at the moment, we're currently implementing the last workitems.

Frans Bouma | Lead developer LLBLGen Pro