How to rename complex type to not having the prefix of the class name

Entity Framework has a standard with the naming of column. This is also the case with complex type which will be added to every tables where complex type are used by entities. By default, Entity Framework will concatenate the name of the complex type with an underscore and the name of the property.

If you prefer not having complex type name, you can simply specify the column name you desire.

         .Property(type => type.CreatedBy)

In the database instead of having a field with “Audit_CreatedBy” you will have only “CreatedBy”. This may be useful in some situation, but by experience it’s easier to do the mapping between complex type when you keep the prefix. It’s up to you, and your coding/database standard, to figure out if it’s appropriate or not.

If you like my article, think to buy my annual book, professionally edited by a proofreader. directly from me or on Amazon. I also wrote a TypeScript book called Holistic TypeScript

1 thought on “How to rename complex type to not having the prefix of the class name

  1. Pingback: Learn Asp Mvc » Sprint 2 : Planning model classes, creating the projects and starting authentification

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.