Adding custom property attributes in Entity Framework code

前端 未结 6 1735
迷失自我
迷失自我 2020-12-08 14:43

Is there any way to add custom attributes to properties in EF generated code? The only thing I can see as a plausible solution would be to come up with a custom T4 template

6条回答
  •  星月不相逢
    2020-12-08 15:18

    I don't believe you can. The generator declares all classes as partial allowing you to extend it, but it will not allow you to mark properties with custom attributes as it will simply generate over them. The one thing you can do is write your own entities.

提交回复
热议问题