views:

297

answers:

1

We have an abstract class where all properties have private setters. In our concrete derived class, the code generator is creating a static “create” method that attempts to set the properties of the abstract class. Obviously this fails since the setters are private.

How do we suppress the creation of the “create” method?

+1  A: 

In v3.5 I don't think you can suppress just this part. However, it will only attempt to set non-nullable/required properties. So I see a few options. None are ideal.

  1. Hang on for v4.0, where you can customize codegen.
  2. Abandon EF codegen altogether and use a custom data class.
  3. Make the properties nullable.
  4. Don't put the properties on the parent type. Put them on the subtypes and use an interface for polymorphism.
  5. Don't make the properties private.
Craig Stuntz
I guess we'll go with door #5 (until we switch to 4.0). Thanks, Craig.
brien