Code Monkey home page Code Monkey logo

Comments (15)

ErikEJ avatar ErikEJ commented on August 23, 2024

PRs are very welcome - does this work for you as desired?

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

Looks like it is related to ErikEJ/SqlCeToolbox#683

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

From @mbharodia on April 12, 2018 15:26

Hi Eric:

The tool you have developed is really useful.

Earlier I used POCO generator for EF 6 and I had an opportunity to extend the context class using partial methods. I have come across many occasions, when I needed to extend the partial context class generated by the tool due to the legacy databases were not designed to support domain driven development; for example, missing Primary Key and Foreign Key did not enable the tool to generate required relationships between parent and child objects.

This can be easily fixed if there is an opportunity to extend this context class by manually writing some code using fluent APIs.

Thanks, and have a good day!

Regards,
Mayur
From: Erik Ejlskov Jensen [email protected]
Sent: April 12, 2018 7:52 AM
To: ErikEJ/SqlCeToolbox [email protected]
Cc: Mayur Bharodia [email protected]; Author [email protected]
Subject: Re: [ErikEJ/SqlCeToolbox] Possibility to introduce templating for on-model-creating method (#695)

PRs are very welcome - does this work for you as desired?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubErikEJ/SqlCeToolbox#695 (comment), or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJ3YweNC_rnEeXBapg_9g-LYJC7fGhi9ks5tn1vqgaJpZM4TR0n7.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

I will try to simply always add the two extra lines:

   OnModelCreatingPartial(modelBuilder);

and

  partial void OnModelCreatingPartial(ModelBuilder modelBuilder);

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

From @mbharodia on April 15, 2018 20:15

Okay. Thanks a lot for your help!

From: Erik Ejlskov Jensen [mailto:[email protected]]
Sent: April 15, 2018 9:37 AM
To: ErikEJ/SqlCeToolbox [email protected]
Cc: Mayur Bharodia [email protected]; Author [email protected]
Subject: Re: [ErikEJ/SqlCeToolbox] Possibility to introduce templating for on-model-creating method (#695)

I will try to simply always add the two extra lines:

OnModelCreatingPartial(modelBuilder);

and

partial void OnModelCreatingPartial(ModelBuilder modelBuilder);


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubErikEJ/SqlCeToolbox#695 (comment), or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJ3YwTrD2rUrGUZmaTGn0ZEO9SdLcV2Uks5to2kpgaJpZM4TR0n7.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

@mbharodia Fixed in latest daily build (no Handlebars required)

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

From @mbharodia on April 28, 2018 13:12

Thank you so much Erik!

From: Erik Ejlskov Jensen [email protected]
Sent: April 28, 2018 3:44 AM
To: ErikEJ/SqlCeToolbox [email protected]
Cc: Mayur Bharodia [email protected]; Mention [email protected]
Subject: Re: [ErikEJ/SqlCeToolbox] Possibility to introduce templating for on-model-creating method (#695)

@mbharodiahttps://github.com/mbharodia Fixed in latest daily build (no Handlebars required)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubErikEJ/SqlCeToolbox#695 (comment), or mute the threadhttps://github.com/notifications/unsubscribe-auth/AJ3YwdQ6Rxo46wGlKU-n8rMOXE1cqEOzks5ttDnMgaJpZM4TR0n7.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

Please let me know if it solves your issue!

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

From @mbharodia on April 30, 2018 17:54

Hi Erik:

It looks like that it is not working as per the expectation. When I got the latest daily build, it generated the following code.

namespace CCData.DataContext
{
    public partial class CustomCareDataContext : DbContext
    {
        public virtual DbSet<Account> Accounts { get; set; }       

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Account>(entity =>
            {
                entity.ToTable("accounts");

                entity.Property(e => e.AccountId).HasColumnName("account_id");

                entity.Property(e => e.AccountIsVerified)
                    .IsRequired()
                    .HasColumnName("account_is_verified")
                    .HasMaxLength(3)
                    .IsUnicode(false)
                    .HasDefaultValueSql("('NRQ')");

                entity.Property(e => e.AccountOpeningBalance)
                    .HasColumnName("account_opening_balance")
                    .HasColumnType("numeric(8, 2)");

                entity.Property(e => e.AccountOpeningDate)
                    .HasColumnName("account_opening_date")
                    .HasColumnType("datetime");

                entity.Property(e => e.AccountStatus)
                    .IsRequired()
                    .HasColumnName("account_status")
                    .HasMaxLength(3)
                    .IsUnicode(false)
                    .HasDefaultValueSql("('ACT')");

                entity.Property(e => e.CompanyId).HasColumnName("company_id");

                entity.HasOne(d => d.Company)
                    .WithMany(p => p.Accounts)
                    .HasForeignKey(d => d.CompanyId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK_accounts_companies");
            });
            
        }

    }
            OnModelCreatingPartial(modelBuilder);
}

I think that the correct code should be like the following. Please pay attention to "OnModelCreatingPartial" at two different places below.

namespace CCData.DataContext
{
    public partial class CustomCareDataContext : DbContext
    {
        public virtual DbSet<Account> Accounts { get; set; }
       

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Account>(entity =>
            {
                entity.ToTable("accounts");

                entity.Property(e => e.AccountId).HasColumnName("account_id");

                entity.Property(e => e.AccountIsVerified)
                    .IsRequired()
                    .HasColumnName("account_is_verified")
                    .HasMaxLength(3)
                    .IsUnicode(false)
                    .HasDefaultValueSql("('NRQ')");

                entity.Property(e => e.AccountOpeningBalance)
                    .HasColumnName("account_opening_balance")
                    .HasColumnType("numeric(8, 2)");

                entity.Property(e => e.AccountOpeningDate)
                    .HasColumnName("account_opening_date")
                    .HasColumnType("datetime");

                entity.Property(e => e.AccountStatus)
                    .IsRequired()
                    .HasColumnName("account_status")
                    .HasMaxLength(3)
                    .IsUnicode(false)
                    .HasDefaultValueSql("('ACT')");

                entity.Property(e => e.CompanyId).HasColumnName("company_id");

                entity.HasOne(d => d.Company)
                    .WithMany(p => p.Accounts)
                    .HasForeignKey(d => d.CompanyId)
                    .OnDelete(DeleteBehavior.ClientSetNull)
                    .HasConstraintName("FK_accounts_companies");
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);

    }
            
}

Additionally, handlebar setup stopped working. I know that you have mentioned that this build is for "no handlebar" support. I guess it is still good to have handlebar to do some customization if needed.

The above explanation may not make sense if I have missed anything that you wanted me to look into before running the templates for your latest daily build. Please let me know your feedback.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

Hmmm... Tried a diferent approach in the latest build

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

@mbharodia I have attempted a fix in the latest daily build, would be grateful if you could try it out

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

@mbharodia ping?

from efcorepowertools.

mbharodia avatar mbharodia commented on August 23, 2024

Hi Erick. That worked well! Thank you.

I am not sure whether it is a lot to ask further, however, is it possible to do the same with POCO classes?

 public partial class Audit
    {
        public Audit()
        {
            **OnModelCreatingPartial();**
        }
        public int AuditId { get; set; }
        public string AuditEntityType { get; set; }
        public string AuditEntityJson { get; set; }
        public DateTime AuditCreateDate { get; set; }
        public string AuditCreatedBy { get; set; }

        **partial void OnModelCreatingPartial();**
    }

Additionally, I don't see handle bar support. Earlier it was easier for me to add extra Using statements to classes generated.

I create POCO classes and DbContext in a separate project and Using Statement is needed in DbContext so that it can reference the project with POCO classes. I am wondering whether handle bar support is going be supported or not.

However, I really appreciate your help with the above.

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

@mbharodia The poco classes are already partial, and OnMoldeCreating does not make any sense here.

The Handlebars feature is temporarily disabled, see #12

from efcorepowertools.

ErikEJ avatar ErikEJ commented on August 23, 2024

@mbharodia Handlebars are back in latest daily build

from efcorepowertools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.