IdentityDbContext

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
Adaś
Posts: 12
Joined: Sat 06 Apr 2019 20:09

IdentityDbContext

Post by Adaś » Mon 25 Jan 2021 17:47

Hi,

how can i use IdentityDbContext in Entity Developer? Any tips?

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: IdentityDbContext

Post by Shalex » Tue 26 Jan 2021 15:14

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.

Adaś
Posts: 12
Joined: Sat 06 Apr 2019 20:09

Re: IdentityDbContext

Post by Adaś » Thu 28 Jan 2021 12:43

.
Last edited by Adaś on Thu 28 Jan 2021 17:01, edited 1 time in total.

Adaś
Posts: 12
Joined: Sat 06 Apr 2019 20:09

Re: IdentityDbContext

Post by Adaś » Thu 28 Jan 2021 16:16

.
Last edited by Adaś on Thu 28 Jan 2021 17:01, edited 1 time in total.

Adaś
Posts: 12
Joined: Sat 06 Apr 2019 20:09

Re: IdentityDbContext

Post by Adaś » Thu 28 Jan 2021 17:01

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);"

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: IdentityDbContext

Post by Shalex » Fri 29 Jan 2021 13:42

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.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: IdentityDbContext

Post by Shalex » Sat 20 Feb 2021 12:52

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.

Post Reply