BaseEnitity - how to do this in EntityDeveloper

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
Adaś
Posts: 12
Joined: Sat 06 Apr 2019 20:09

BaseEnitity - how to do this in EntityDeveloper

Post by Adaś » Mon 17 May 2021 19:17

Hi,

my code looks like this:

Code: Select all

    public class BaseEntity
    {
        public int Id { get; set; }
        public DateTime CreatedDate { get; set; }
        public DateTime ModifiedDate { get; set; }
        public bool IsActive { get; set; }
        public bool IsDeleted { get; set; }
    }

Code: Select all

    public class Customer : BaseEntity
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
    }
and mappings

Code: Select all

    public class CustomerMap : IEntityTypeConfiguration<Customer>
    {
        public void Configure(EntityTypeBuilder<Customer> builder)
        {
            builder.HasKey(x => x.Id).HasName("pk_customerid");
            builder.Property(x => x.Id).ValueGeneratedOnAdd().HasColumnName("id");

            builder.Property(x => x.FirstName).HasColumnType("varchar(50)");
            builder.Property(x => x.LastName).HasColumnType("varchar(50)");



            builder.Property(x => x.CreatedDate)
                .HasColumnName("created_date")
                .HasColumnType("datetime");

            builder.Property(x => x.ModifiedDate)
                .HasColumnName("modified_date")
                .HasColumnType("datetime");

            builder.Property(x => x.IsActive)
                .HasColumnName("is_active")
                .HasColumnType("bit")
                .HasDefaultValue(1);

            builder.Property(x => x.IsDeleted)
                .HasColumnName("is_deleted")
                .HasColumnType("bit")
                .HasDefaultValue(0);
        }
    }
How can i do the same in entity developer? I can set BaseType to BaseEntity but when i generate code there is no mapping for properties from BaseEntity class.

Shalex
Site Admin
Posts: 9543
Joined: Thu 14 Aug 2008 12:44

Re: BaseEnitity - how to do this in EntityDeveloper

Post by Shalex » Tue 18 May 2021 13:54

Be aware that EF Core supports only TPH and TPT inheritances. TPC is not yet supported by EF Core.

Refer to https://www.devart.com/entitydeveloper/ ... s-efc.html.

Post Reply