Security - DB / Model Design

Hello, not sure if I'm going to be able to articulate this question properly, please let me know if it doesn't quite make sense ... I may be trying something silly :wink:

  1. I want to setup security for my application and map a users account to a contact/customer type record.
    The problem I cant get my head around currently is that on generating an app from and existing schema and then adding security I end up with two DBContexts...Not sure how to map my Contact entity to the ASPNetUser. To add an anotherlayer of complexity I would like to relationship between AspNetUser and Contact to be 0..1 to 0..1. Can you advise how to achieve this?

  2. I've been thinking about how best I would like to tackle this design with the tools at hand and I always come back to EF Migrations. Is it possible to build my DB model through Radzen with EF migrations rather than specifying my DB schema first?
    That is, create my Radzen application, create an empty DB for the Radzen Data Source screen, add Aspnet security through the Radzen Security screen then head in to Visual Studio and begin building my model. Once happy, use the Radzen generated ApplicationIdentityDbContext as my single application context and add an EF migration to generate the rest of the DB. I understand that no metadata would be generated, but I am hoping I could go back into Radzen data screen and run the infer schema wizard to see all that taken care of without seeing my context modified.

I've included a screenshot pf my Db schema below ... I've gone a bit crazy on normalization :wink:

Any help or guidence you can provide would be appreciated and please let me know if you need any additional clarification as to what I am trying to acheive.

Thanks and regards

Hi Jason,

Probably this section from the Create a Complete Application tutorial would help. It shows how to create a foreign key property to the AspNetUsers table and use it.

Hi Korchev,

Thanks for this tutorial it is very good.
But I have tried adding a foreign key to the AspNetUser table, and it is not working fully. The database seems to be correctly configured but Blazor is not giving me access to the user table when I try to add an Opportunity. The Opportunities table is showing the user name but not on adding.

The demo on Github is also not giving access to the user, the only user field is for a User Id:

What am I missing?


The User is set from C# code to the currently logged one. This form field should be removed from the form altogether. Here is the relevant section from the documentation.

I think what Riaan_Havenga is trying to do is assign this opportunity to a user. A dropdown list would be best for this purpose.