Cannot move OpenIddict entities to custom schema after new version
See original GitHub issueHi, I have been putting the OpenIddict entities in their own “OpenIddict” schema in my database. It has worked fine until the latest version.
Right now, it is creating the tables in the “OpenIddict” schema like I want it to, but it is also creating the default schema (public as I’m using PGSQL) as well.
Any suggestions? I’m sure I’m just missing something in my Startup.cs.
Thanks!
In my Startup.cs
public void ConfigureServices(IServiceCollection services)
{
....
services.AddEntityFrameworkNpgsql().AddDbContextPool<AppDbContext>(options =>
{
options.UseNpgsql(Configuration["pgsql:housestay"], b => b.MigrationsAssembly("HouseStayEF"));
options.UseOpenIddict();
});
....
services.AddOpenIddict()
.AddCore(options =>
{
options.UseEntityFrameworkCore().UseDbContext<AppDbContext>();
})
.AddServer(options =>
{
options.UseMvc();
options.EnableTokenEndpoint("/auth/token");
options.AllowPasswordFlow();
//options.AllowCustomFlow(GrantTypes.Facebook);
//options.AllowCustomFlow(GrantTypes.Google);
options.AllowRefreshTokenFlow();
//options.AcceptAnonymousClients();
options.RegisterScopes(
OpenIdConnectConstants.Scopes.Email,
OpenIdConnectConstants.Scopes.Profile,
OpenIddictConstants.Scopes.Roles
);
options.SetAccessTokenLifetime(TimeSpan.FromHours(1));
options.SetRefreshTokenLifetime(TimeSpan.FromDays(180));
if (!_isProduction)
{
options.DisableHttpsRequirement();
}
});
....
}
In my AppDbContext.OnModelCreating:
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
.....
builder.Entity<OpenIddictApplication>(e => { e.ToTable("Applications", "OpenIddict"); });
builder.Entity<OpenIddictAuthorization>(e => { e.ToTable("Authorizations", "OpenIddict"); });
builder.Entity<OpenIddictScope>(e => { e.ToTable("Scopes", "OpenIddict"); });
builder.Entity<OpenIddictToken>(e => { e.ToTable("Tokens", "OpenIddict"); });
.....
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:13 (6 by maintainers)
Top Results From Across the Web
How to force creation of OpenIddict tables in not empty DB
The only way is to create own Stores and StoreResolvers for OpenIddict and migrate tables creation to any suitable solution: a set of...
Read more >modules/openiddict | Documentation Center | ABP.IO
The OpenIddict module adds the following items to the "Main" menu, under the "Administration" menu item: Applications: Application management page. Scopes: ...
Read more >Migrate to OpenIddict 3.0
Migrating to OpenIddict 3.0 requires making changes to your database: existing properties have been reworked and new ones have been added to support...
Read more >Getting started - OpenIddict documentation
To implement a custom OpenID Connect server using OpenIddict, the simplest option is to clone one of the official samples from the openiddict-samples ......
Read more >Introducing OpenIddict 3.0 beta1 | Kévin Chalet's blog
In this post, discover the major changes introduced in OpenIddict 3.0.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You can use the ASP.NET Core authorization policy builder:
policy.RequireClaim(OAuthValidationConstants.Claims.Scope, "marketing_api")
.Sorry, I missed that announcement. I removed the deprecated package and updated my DbContext OnModelCreating to use the models from OpenIddict.EntityFrameworkCore.Models instead.
Works as expected now. Thanks for your help. OpenIddict has been very useful!