I am using ASP.NET Core 2.0 with Identity and Entity Framework. I have extended the IdentityUser
class into the ApplicationUser
below:
namespace TxTools.Data.Features.Shared.Models
{
public class ApplicationUser : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
[ForeignKey("PhotoResourceId")]
public BlobResource Photo { get; set; }
}
}
Here is my BlobResource
:
namespace TxTools.Data.Features.BlobStorage.Models
{
public class BlobResource
{
[Key]
public Guid ResourceId { get; protected set; }
public string Container { get; protected set; }
public string MimeType { get; protected set; }
public string Filename => String.Format("{0}.{1}", ResourceId, MimeTypes.GetExtension(MimeType));
public BlobResource(string container, string mimeType)
{
this.ResourceId = Guid.NewGuid();
this.Container = container;
this.MimeType = mimeType;
}
}
}
Entity Framework saves the BlobResource
when I add it to the ApplicationUser
, but I cannot get it to load the BlobResource
from the database. The object is always null. I have tried several Fluent API commands to try and get it to load, but none work.