实体框架:如何设置模型实体框架为Serializable

编程入门 行业动态 更新时间:2024-10-09 00:45:35
本文介绍了实体框架:如何设置模型实体框架为Serializable的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 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; } }

正如你可以在我的code看到,我的课堂设置好的为可序列化。但经过更新我的.edmx文件,该设置删除。我怎样才能更新后的文件EDMX保持序列化?

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?

推荐答案

正如你可以看到你的类是局部的,所以你可以添加其他类(文件)到你的项目和使用Serializable属性那里。

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 { }

与相同的命名空间中的另一个类将这个也看msdn.microsoft/en-us/library/wa80x488(v=vs.90).aspx有关谐音进一步的信息。

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

更多推荐

实体框架:如何设置模型实体框架为Serializable

本文发布于:2023-11-12 14:19:31,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1581726.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:实体   框架   如何设置   模型   Serializable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!