Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Accessing User Entity from code #1444


User avatar
0
jamsecgmbh created

Dear ASP.NET Boilerplate Support,

I want to use data from the User table in my code - how can I make it accessible? Do I need to create an IDbSet manually in the DbContext class?

Thank you very much and best regards Chris


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    How do you want to use User table's data ? User entity is alredy included in DbContet.

    You can get users by UserManager class.

  • User Avatar
    0
    jamsecgmbh created

    Thank you!

    How can I create a foreign key pointing to the id of an user in the user table?

    [Table("DbAppTesttable")]
    public class Testtable : FullAuditedEntity<long>, IMustHaveTenant
    {
        // Foreign Key: ID of User
        [ForeignKey("User ...
        ...
    }
    
  • User Avatar
    0
    ismcagdas created
    Support Team

    It should be something like this,

    [ForeignKey("UserId")]
    public virtual User User { get; set; }
    
    public virtual long UserId { get; set; }