question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Possible to support 1.0.0-* and 2.0.0-rc2-0792 in same sql db?

See original GitHub issue

I’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

oldschema newschema

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
toddtsiccommented, Jan 20, 2018

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

0reactions
toddtsiccommented, Jan 16, 2018

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:

Its not, but I’m noticing you have left “breadcrumb” clues such as:

        services.AddDbContext<SqlDbContext>(options =>
        {
            options.UseSqlServer(
                Configuration.GetConnectionString("DefaultConnection")
            );

            // Register the entity sets needed by OpenIddict.
            // Note: use the generic overload if you need
            // to replace the default OpenIddict entities.
            options.UseOpenIddict();
        });

“replacing the default OpenIddict entities” is exactly what I’m aiming to do, let me take some time to follow up on your clues such as above and see if I can get things working. Don’t want to take your time until I do.

T

On Mon, Jan 15, 2018 at 11:47 AM, Kévin Chalet notifications@github.com wrote:

It’s hard to say without seeing your code or trying it locally. Is your source code visible somewhere?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/openiddict/openiddict-core/issues/534#issuecomment-357761619, or mute the thread https://github.com/notifications/unsubscribe-auth/AJeirwp7Qdz5sOhDgt-QMpsT4haiUEW2ks5tK504gaJpZM4ReoVY .

– Todd Greenwald President, TeamSportsInfo.com tgreenwald@teamsportsinfo.com 410-703-3450

– Todd Greenwald President, TeamSportsInfo.com tgreenwald@teamsportsinfo.com 410-703-3450

Read more comments on GitHub >

github_iconTop Results From Across the Web

TLS 1.2 support for Microsoft SQL Server
This article provides information about the updates that Microsoft releases to enable TLS 1.2 support for SQL Server.
Read more >
Enable TLS 1.2 for SQL Server 2016 database mail
Yes. SQL Server 2016 and SQL Server 2017 on Windows versions ship with TLS 1.0 to TLS 1.2 support. You have to disable...
Read more >
Zero Downtime Deployment with a Database
This article will explain in depth how to tackle issues related to database compatibility and the deployment process.
Read more >
Enable TLS on SQL Server
In this post, you'll learn how to enable TLS on your SQL Server. ... SQL Server has long supported SSL encryption, but due...
Read more >
Does Microsoft OLE DB Provider for SQL Server support ...
This new driver includes the support for the latest TLS 1.2 standards and is backwards compatible with SQL Server Native Client 11 (SQLNCLI11)....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found