Efcore: DB scaffold CLI Removes DBSET<t> (dbquery<t>)

Created on 16 Nov 2019  Â·  5Comments  Â·  Source: dotnet/efcore

Since the Dbscaffold CLI replaces dbcontext c# file each time. In order to use ef cores new dbSet (the new dbquery) you have to put into this (auto wiped out by the CLI) dbcontext file as a.HasNoKey() item.

In efc2 the dbquery we kept it in a partial class so it wouldn't get over written by the scaffold. Since we can't put dbSets in a different c# file because we need to add hasnoKey() in onmodelbuilding event (which gets over written by the scaffold), we have to stay on 2.0

Would really like to upgrade to EF core 3.0 but since they deprecated DBquery into something new that breaks db scaffolding for us we can't.

The only nuGet we haven’t updated in our core3.0 build is this efcore3.0 one. 😅

EF Core version: 3.0
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: NET Core 3.0
Operating system: win10 x64
IDE: Visual Studio 2019 16.3.8

closed-question customer-reported

All 5 comments

You are a bit unclear, but with EF Core 3, you can override the OnModelCreatingPartial partial method

How? Because the on model creating auto generated by the db scaffold CLI is already an override? Can you have 2 overrides? Will it run both overrides?

Logan

On Nov 16, 2019, at 5:08 PM, Erik Ejlskov Jensen notifications@github.com wrote:



You are a bit unclear, but with EF Core 3, you can override the OnModelCreatingPartial partial method

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/aspnet/EntityFrameworkCore/issues/18944?email_source=notifications&email_token=AEYSEODT35W7AK4MH462IUTQUBVNRA5CNFSM4JOGD3LKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEH3UCI#issuecomment-554678793, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEYSEOEGXMNJ2HQV7KB3J3DQUBVNRANCNFSM4JOGD3LA.

Have a close look at the last lines of the generated DbContext

I did look at it, not sure what your subtly inferring? Can you be more direct?

Logan

On Nov 16, 2019, at 5:50 PM, Erik Ejlskov Jensen notifications@github.com wrote:



Have a close look at the last lines of the generated DbContext

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://github.com/aspnet/EntityFrameworkCore/issues/18944?email_source=notifications&email_token=AEYSEOGETRBLO4GANFDE5ILQUB2KVA5CNFSM4JOGD3LKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEEH4KCI#issuecomment-554681609, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AEYSEOAQSTZCTMOHAU3TO4TQUB2KVANCNFSM4JOGD3LA.

Was this page helpful?
0 / 5 - 0 ratings