PostSharp inserting k__Backing Field into Entity Class, causing Database generation to fail

前端 未结 1 942
粉色の甜心
粉色の甜心 2021-01-19 03:44

I\'m creating a Database using the Microsoft Entity Framework and CodeFirst in C#. I want to use the Database in a WPF-Application, so the Entity-Classes should implement \"

相关标签:
1条回答
  • 2021-01-19 04:03

    It's true that PostSharp can create a property called k__BackingField (the real name is a bit different; what you're seeing is the escapes name), because I suppose you're applying the aspect to fields, which causes PostSharp to encapsulate fields into properties of the same name. So, you can have a property named after the field.

    You should check whether you really want to add the aspect to the field. Perhaps you just wanted to add the aspect to properties, but are adding it to fields by mistake. By default, LocationInterceptionAspects are applied (multicast) fo fields and properties. Use MulticastAttributeUsageAttribute.AttributeTargets to restrict it to properties.

    0 讨论(0)
提交回复
热议问题