Use ComplexTypes for the standard columns

In the entity framework code first it's a nice idea to arrange your standard colums for all tables in ComplexTypes. Standard columns can be columns like entrydate, user etc.
Example ComplexType:

    [ComplexType]
    public class RecordDetail
    {
        [Column("User")]
        public string User { get; set; }

        [Column("CreateDate")]
        public DateTime CreateDate { get; set; }

        [Column("EditDate")]
        public DateTime EditDate { get; set; }

        [Column("Description")]
        public string Description { get; set; }
    }

So, a complex type is simple a class with property's. According the documentation it should not be neccessary to decorate the class with the ComplexType attribute. The entity framework should investigate the class and detect that it doesn't have a primairy key so it must be a ComplexType. The same with the property's it shouldn't be necessary to decorate it with the Column attribute but in some cases it doesn't match the right colums.

Use the complex type in a Entity Framework class:

    public class ContactPerson
    {
        public int Id { get; set; }

        public string Firstname { get; set; }

        public string PreFix { get; set; }

        public string LastName { get; set; }

        public DateTime BirthDate { get; set; }

        public RecordDetail RecordDetail { get; set; }

    }

Big advantage of the use of ComplexTypes like this is that you just have to create a sinlge class and use this in all the EntityFramework classes. Disadvantage is that changing only a property of the ComplexType doesn't set the modified property for the record and it that case wouldn't be saved to the database. You have to set in that case the modfified property yourself.

{{opmerking.Naam}}:

{{opmerking.OpmerkingText}}

            

Saving your comment....

Naam is verplicht!
Email is verplicht!
Opmerking is verplicht!