-
-
Notifications
You must be signed in to change notification settings - Fork 481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removal of OpenIddict.Models in OpenIddict RC3 #608
Comments
Just wondering when will the samples be updated to reflect this change? I am having some trouble migration from rc2 - when calling services.AddOpenIddict, where do I put the additional calls to methods such as AddMvcBinders, RegisterScopes, SetAccessTokenLifetime etc.? These methods are not available on the options object inside the the AddOpenIddict method or the AddCore method. For example, inside of AddOpenIddict it used to look like this:
|
Note that the samples hosted in this repository target RC3: https://github.com/openiddict/openiddict-core/blob/dev/samples/Mvc.Server/Startup.cs |
Thank you! I had missed #593 and the sample code helped as well. I was able to get everything to work. (I'm using the implicit flow and JWTs). I will check back to see the updated sample code for implicit flow when it is available later. FYI - one difference I noted in the sample code as compared with #593 is that the line: |
@PinpointTownes What do you make of this error? This is happening on
My code looks pretty identical to the example you've shared as well. |
@PinpointTownes That certainly got me closer because I wasn't calling it. After adding that bit of code that you suggested and running I am getting another error that reads like this:
Is there some option I am missing? |
Are you migrating from an old OpenIddict version (e.g RC1?). If so, you'll have to update your DB schema. Read https://openiddict.github.io/openiddict-documentation/guide/migration.html for more information. |
Ohhhhh, yeah I am. Thanks. |
@PinpointTownes All I did was make the migrations, run the migrations and all is well -- there are additional steps... are these necessary? It looks like everything is working properly without them. |
@sethen you should run the migration script to convert existing DB entries to the new denormalized JSON model. If you don't do that, you may see exceptions at runtime. |
Starting with RC3, OpenIddict will no longer come with a default set of entities and stores base classes.
Why?
In the previous iterations of OpenIddict, an important effort was made to create a shared set of entities (contained in the
OpenIddict.Models
package) that could be used not only by the official Entity Framework 6.x and Entity Framework Core stores, but also by third-party/custom stores.This pattern had many pros - like avoiding code duplication or having base classes that simplify the development of custom stores (which is why it was also eventually adopted by the ASP.NET team for ASP.NET Core Identity in 2.0).
Unfortunately, this approach had also a major issue: we had to design the default entities as "lowest common denominators", so that they could be used by all/most ORMs or document databases. In practice, this meant that things like
OpenIddictApplication.RedirectUris
orOpenIddictApplication.PostLogoutRedirectUris
had to be represented as JSON-serializedstrings
for SQL-oriented ORMs like EF 6.x and EF Core to work natively.In the document databases world, entities are generally schema-less, which offers a greater flexibility. A NoSQL database like MongoDB can easily store and efficiently index JSON arrays, which means
OpenIddictApplication.RedirectUris/PostLogoutRedirectUris
are best represented as arrays of strings (string[]
).The conclusion was clear: we couldn't have the best performance by using non-optimized entities.
What will change?
In RC3, each stores package will come with its own models you'll be able to use exactly like in the previous iterations.
How do I update my code?
First, make sure you don't reference the obsolete
OpenIddict.Models
orOpenIddict.Stores
packages. The new models are automatically referenced by the stores packages they belong to and you don't need to add any reference to use them.Then, update your
Startup.ConfigureServices()
method to use the new helpers. For instance:If you prefer using
long
as the key type (with the default entities), useReplaceDefaultEntities
:If you want to use your own entities instead of the default EF Core ones:
The text was updated successfully, but these errors were encountered: