diff --git a/src/Core/Models/EntityFramework/Cipher.cs b/src/Core/Models/EntityFramework/Cipher.cs index 4d4986ecdc..6edfe8773b 100644 --- a/src/Core/Models/EntityFramework/Cipher.cs +++ b/src/Core/Models/EntityFramework/Cipher.cs @@ -7,6 +7,8 @@ namespace Bit.Core.Models.EntityFramework { private JsonDocument _dataJson; private JsonDocument _attachmentsJson; + private JsonDocument _favoritesJson; + private JsonDocument _foldersJson; public User User { get; set; } public Organization Organization { get; set; } @@ -16,7 +18,7 @@ namespace Bit.Core.Models.EntityFramework get => _dataJson; set { - Data = value.ToString(); + Data = value?.ToString(); _dataJson = value; } } @@ -26,10 +28,30 @@ namespace Bit.Core.Models.EntityFramework get => _attachmentsJson; set { - Attachments = value.ToString(); + Attachments = value?.ToString(); _attachmentsJson = value; } } + [IgnoreMap] + public JsonDocument FavoritesJson + { + get => _favoritesJson; + set + { + Favorites = value?.ToString(); + _favoritesJson = value; + } + } + [IgnoreMap] + public JsonDocument FoldersJson + { + get => _foldersJson; + set + { + Folders = value?.ToString(); + _foldersJson = value; + } + } } public class CipherMapperProfile : Profile diff --git a/src/Core/Models/EntityFramework/Organization.cs b/src/Core/Models/EntityFramework/Organization.cs index 3532f52dac..2ee5c4c190 100644 --- a/src/Core/Models/EntityFramework/Organization.cs +++ b/src/Core/Models/EntityFramework/Organization.cs @@ -16,7 +16,7 @@ namespace Bit.Core.Models.EntityFramework get => _twoFactorProvidersJson; set { - TwoFactorProviders = value.ToString(); + TwoFactorProviders = value?.ToString(); _twoFactorProvidersJson = value; } } diff --git a/src/Core/Models/EntityFramework/User.cs b/src/Core/Models/EntityFramework/User.cs index c945cbd0d4..5f1aff6daa 100644 --- a/src/Core/Models/EntityFramework/User.cs +++ b/src/Core/Models/EntityFramework/User.cs @@ -16,7 +16,7 @@ namespace Bit.Core.Models.EntityFramework get => _twoFactorProvidersJson; set { - TwoFactorProviders = value.ToString(); + TwoFactorProviders = value?.ToString(); _twoFactorProvidersJson = value; } } diff --git a/src/Core/Repositories/EntityFramework/DatabaseContext.cs b/src/Core/Repositories/EntityFramework/DatabaseContext.cs index 69ca779254..df418a0ee0 100644 --- a/src/Core/Repositories/EntityFramework/DatabaseContext.cs +++ b/src/Core/Repositories/EntityFramework/DatabaseContext.cs @@ -20,6 +20,10 @@ namespace Bit.Core.Repositories.EntityFramework builder.Entity().Property(e => e.DataJson).HasColumnName("Data"); builder.Entity().Ignore(e => e.Attachments); builder.Entity().Property(e => e.AttachmentsJson).HasColumnName("Attachments"); + builder.Entity().Ignore(e => e.Favorites); + builder.Entity().Property(e => e.FavoritesJson).HasColumnName("Favorites"); + builder.Entity().Ignore(e => e.Folders); + builder.Entity().Property(e => e.FoldersJson).HasColumnName("Folders"); builder.Entity().Ignore(e => e.TwoFactorProviders); builder.Entity().Property(e => e.TwoFactorProvidersJson).HasColumnName("TwoFactorProviders");