Serializable classes and dynamic proxies in EF - how?

前端 未结 5 462
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-29 12:08

In [a previous posting], I was set on the path to having to clone my entities. This I\'ve attempted to do with a serialisation approach as found in [codeproject].

b

5条回答
  •  無奈伤痛
    2020-11-29 12:30

    I had the same issue using Entity Framework 6 ( EF6 ). I fixed the issue by changing the T4 template and adding the line [Serializable] between the Using Directives and the Entity Class Opening line. Like so:

     <#=codeStringGenerator.UsingDirectives(inHeader: false)#>
     [Serializable]
     <#=codeStringGenerator.EntityClassOpening(entity)#>
    

    No other changes required.

提交回复
热议问题