Possible to support 1.0.0-* and 2.0.0-rc2-0792 in same sql db?
See original GitHub issueI’m supporting a mobile app that is getting heavy use using OpenIdDict @ 1.0.0-*.
Now writing new Asp.NetCore 2.0 backend for the api calls from the mobile app and I’m using OpenIdDict 2.0.0-rc2-0792.
I needed to commit to database first approach (to continue mobile support), so my first move was using Visual Studio 2017, I loaded solution downloaded from OpenIdDict.Samples and focused on implicit flow server project. I used Visual Studio’s Sql Server Object Explorer, then scripted “create” for each of the four OpenIdDict tables, but modified the script to use schema [auth] and not [dbo], (In order to not overwrite the current [dbo].OpenIdDictxxx tables.)
In the new api project I then scaffolded using:
dotnet ef dbcontext scaffold "Server=.\XXX;Database=XXXX;Trusted_Connection=True;" "Microsoft.EntityFrameworkCore.SqlServer" -o "SqlModels" -c "SqlDbContext" -f
Entity Framework takes in both versions of each of the four OpenIdDict tables (note the new Scopes table create script doesn’t define a primary key so I had to add by hand) and names the first one it sees alphabetically, as the named table, the second one appends “1”. (so auth.OpenIddict.Applications appears as
OpenIddictApplications
and dbo.OpenIddict.Applications appears as
OpenIddictApplications1
)
I purposefully use schema [auth] to sort before [dbo] hoping that the net project OpenIddict modules would address the tables without the “1” appended.
At this point in the api project I simply copied and adapted the startup.cs from the OpenIddict.Samples implicit server project and couldn’t get past in startup.cs:
if (await manager.FindByClientIdAsync(Configuration["JwtTokenParams:ClientID"], cancellationToken) == null)
Message=Cannot use table ‘OpenIddictApplications’ for entity type ‘OpenIddictApplications’ since it is being used for entity type ‘OpenIddictApplication’ and there is no relationship between the primary key {‘Id’} and the primary key {‘Id’}.
With that error I modified
services.AddOpenIddict(options =>
{
// Register the Entity Framework stores.
options.AddEntityFrameworkCoreStores<SqlDbContext>();
to
services.AddOpenIddict<OpenIddictApplications, OpenIddictAuthorizations, OpenIddictScopes, OpenIddictTokens>(options =>
{
// Register the Entity Framework stores.
options.AddEntityFrameworkCoreStores<SqlDbContext>();
Then receive at:
// Register the Entity Framework stores.
options.AddEntityFrameworkCoreStores<SqlDbContext>();
Message=The Entity Framework Core stores can only be used with the built-in OpenIddictApplication entity.
Conceptually, I was wondering if I could rename my new schema (schema diagrams below of both 1.0.0-* tables and 2.0.0-rc-0792 tables) and using ? AddOpenIddict() indicate a mapping to the new table. (Thus avoiding any naming conflicts)
Any assistance here would be greatly appreciated. Starting with a new blank database is not an option.
Todd
Issue Analytics
- State:
- Created 6 years ago
- Comments:8 (3 by maintainers)
Top GitHub Comments
Kevin,
I was able to get things working by following your lead in https://github.com/openiddict/openiddict-core/issues/360 That did the trick, thanks!
Todd
Hey Kevin,
I’ve looked at this more carefully… Do you have a few minutes to discuss? (if so, how would you like to discuss, gitter, email…?)
T
On Mon, Jan 15, 2018 at 11:55 AM, Todd Greenwald < tgreenwald@teamsportsinfo.com> wrote:
– Todd Greenwald President, TeamSportsInfo.com tgreenwald@teamsportsinfo.com 410-703-3450