Entity Framework: How to set model as Serializable in Entity Framework

筅森魡賤 提交于 2019-12-11 02:48:18

问题


using System;
using System.Collections.Generic;
[Serializable]
public partial class user
{
    public int UserId { get; set; }
    public string Name { get; set; }
    public string Surname { get; set; }
    public string UserName { get; set; }
    public string Email { get; set; }
    public string Password { get; set; }
    public System.DateTime Creation { get; set; }
    public bool Status { get; set; }
    public int UserTypeId { get; set; }
}

As you can see in my code, my class setted as serializable. But after I update my .edmx file, this setting deleted. How can I keep Serializable after update edmx file?


回答1:


As you can see your class is partial so you can add another class(file) to your project and use Serializable attribute there.

[Serializable]
public partial class user
{

}

Put this in another class with the same namespace and also see http://msdn.microsoft.com/en-us/library/wa80x488(v=vs.90).aspx for further info about partials.



来源:https://stackoverflow.com/questions/18693262/entity-framework-how-to-set-model-as-serializable-in-entity-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!