Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IdentityServer4.Models vs IdentityServer4.EntityFramework.Entities

I like to use the EntityFramework for persistence of the IndentityServer4 configuration data. But I was wondering why the same model Classes are duplicated in Model / Entities? Are both models always kept in sync? If I use the Entities, can I still include the Models project to use some convenient const and enum classes which are available in Models but not in Entities? Or is it better when using Entities to not include the Models library to prevent confusion.

Please advice.

like image 838
fantastischIdee Avatar asked Dec 08 '22 19:12

fantastischIdee


1 Answers

The Models are duplicated in the IdentityServer4.EntityFramework library so that the models can be mapped to entities that make sense to Entity Framework (see the many lists of strings that need to be turned into entities so that they can be stored in separate tables). These entities are kept in sync by the IdentityServer team and the community.

There are mapper extensions for both types to convert them into one another: ToModel() and ToEntity().

Always use the Models unless you are communicating directly with the database.

like image 163
Scott Brady Avatar answered Jan 17 '23 06:01

Scott Brady