I have a class called User
and it is [Serializable]
and inherited from base class IdentityUser
an Entity Framework class and Non Serializable.
I have a property in Booking
class with type User
and Booking
class is Serializable
I am trying to serialize the booking object using BinaryFormatter
but I can't because of IdentityUser
class and I get this error :
'Type 'Microsoft.AspNet.Identity.EntityFramework.IdentityUser' in Assembly 'Microsoft.AspNet.Identity.EntityFramework, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable.'
Is there a way to ignore this property because I don't think there is away to make 'IdentityUser' as Serializable.
[Serializable]
public class User : IdentityUser
{
public String FirstName { get; set; }
}
[Serializable]
public class Booking
{
[ForeignKey("Guest")]
public string GuestId { set; get; }
public virtual User Guest { set; get; }
}