Page 1 of 1
IdentityDbContext
Posted: Mon 25 Jan 2021 17:47
by Adaś
Hi,
how can i use IdentityDbContext in Entity Developer? Any tips?
Re: IdentityDbContext
Posted: Tue 26 Jan 2021 15:14
by Shalex
The new extended model property Base Context Type is added in Entity Developer v6.10.1165 for specifying a parent class for the generated context in EF Core Model.
Re: IdentityDbContext
Posted: Thu 28 Jan 2021 12:43
by Adaś
.
Re: IdentityDbContext
Posted: Thu 28 Jan 2021 16:16
by Adaś
.
Re: IdentityDbContext
Posted: Thu 28 Jan 2021 17:01
by Adaś
It works but...
- when context base class is IdentityDbContext its missing "using Microsoft.AspNetCore.Identity.EntityFrameworkCore;" - it can be fixed by setting base to class to: Microsoft.AspNetCore.Identity.EntityFrameworkCore.IdentityDbContext
- protected override void OnModelCreating(ModelBuilder modelBuilder) need "base.OnModelCreating(modelBuilder);" which is removed everytime when code is generated
- other base classes like "IdentityUser" or "IdentityRole" need also "using Microsoft.AspNetCore.Identity;" or full namespace.
Summary:
- the real problem is "base.OnModelCreating(modelBuilder);"
Re: IdentityDbContext
Posted: Fri 29 Jan 2021 13:42
by Shalex
Adaś wrote: ↑Thu 28 Jan 2021 17:01
- protected override void OnModelCreating(ModelBuilder modelBuilder) need "base.OnModelCreating(modelBuilder);" which is removed everytime when code is generated
We are going to update the predefined template to generate "base.OnModelCreating(modelBuilder);" if the Base Context Type model property is set. We will notify you when a new public build of Entity Developer is available for download.
Re: IdentityDbContext
Posted: Sat 20 Feb 2021 12:52
by Shalex
Code generation is improved: OnModelCreating(modelBuilder) of the base class is invoked now if the Base Context Type property of EF Core Model is initialized. Refer to
viewtopic.php?f=32&t=44483.