Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • Carl S 7 posts 87 karma points
    May 16, 2017 @ 10:39
    Carl S

    Custom database table and referencing member table

    I want to create a custom datatable and reference member id as a ForeignKey - But when I do like below I get an Null reference on ForeignKey-attribute (Umbraco.Core.Models.Member) .

    I've "googled" and searched this forum but can't find any relevant answer.

    Which type must I use in the attribute?

    [PrimaryKey(nameof(OrderId), autoIncrement = true)]
    public class OrderTable
        [PrimaryKeyColumn(AutoIncrement = true, Clustered = true, IdentitySeed = 1)]
        public int OrderId { get; set; }
        [ForeignKey(typeof(Member), Column = nameof(Member.Id))]
        public int MemberId { get; set; }
        public DateTime CreatedDate { get; set; }
  • David Brendel 792 posts 2969 karma points MVP 2x c-trib
    May 16, 2017 @ 10:46
    David Brendel

    Hi Carl,

    not sure that it is possible at all to reference Umbraco internals like content or members like this.

    Think the best way would be to just save the id and then fetch the member using the umbraco services.

    At least this is how I done it when I needed references to something like member.

    Regards David

  • Carl S 7 posts 87 karma points
    May 16, 2017 @ 11:27
    Carl S

    Hi David,

    Ah that's too bad you have do to it that way. But I do understand it too.


Please Sign in or register to post replies

Write your reply to: