Efcore: 3.0 Upgrade - Entity with HasNoKey() (formerly a query type) tries to create tables when adding migration

Created on 28 Sep 2019  路  2Comments  路  Source: dotnet/efcore

I have the following Entity which used to be a query type:

``` C#
modelBuilder
.Entity()
.HasNoKey();

As a query type it caused no issues, but now that it's an entity, migrations are trying to create tables for it.

I have several entities defined like so, none of which attempt table generation when adding a migration. I assume it's because of the ToView():

``` C#
modelBuilder
    .Entity<AreaUserInfo>()
    .HasNoKey()
    .ToView("v_AreaUserInfos");

The problem is that my above entity types come out of a stored procedure. It's not a View or a Table.

I don't want to have to manually modify every migration going forward to account for this. Is there a way to prevent table generation when creating migrations?

Further technical details

EF Core version: 3.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: .NET Core 3.0
Operating system: Windows 10
IDE: Visual Studio 2019 16.3

closed-duplicate customer-reported

Most helpful comment

Related to #17270 and #2725.

For now, you can just use something like .ToView("You forgot to use FromSql with ModQueueEntry")

All 2 comments

Related to #17270 and #2725.

For now, you can just use something like .ToView("You forgot to use FromSql with ModQueueEntry")

Note from triage: closing this as duplicate since the work here is covered by #17270 and #2725.

Was this page helpful?
0 / 5 - 0 ratings