Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "drblakl"

Hello!

Using Asp.NET MVC 5 project and wondering what the best practice is to eager load required children of a Repository.

Do we need to make a custom repository to GetAllIncluding(), or is there another way that will load specific required children all the time if available?

Thank you in advance!

Hello!

I'd like to make a Custom ActionFilterAttribute and within that class use one of my application services, as well as the AbpSession.

How would I go about doing this?

Thank you!

Hello all!

I've posted this on stackoverflow related to entityframework but haven't gotten many responses, so I'm hoping one of you can enlighten me. Perhaps my strategy is all wrong or thinking is not quite in the right place. Might just be my lack of understanding of EntityFramework and how it works. I'm okay with using straight data annotations, or OnModelCreating(). I think I'm just missing a few pieces to ensure the chain is inserted properly, and goes from there.

For this example, we have a Student Entity which has a one to one relationship with ImmunizationRecord. ImmunizationRecord has a one to Many relationship to ShotRecord. A student can only have one ImmunizationRecord, but every ImmunizationRecord can have many ShotRecords.

Where I'm at now I currently get the following error on insert of Student.

abp InvalidOperationException: A dependent property in a ReferentialConstraint is mapped to a store-generated column. Column: 'Id'.

Here are my entity snippets:

Student

[Table("tblStudent")]   
    public class Student : FullAuditedEntity, IMustHaveTenant
    {
        public Student()
        {
            ImmunizationRecord = new ImmunizationRecord();
        }

        [Key]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public override int Id { get => base.Id; set => base.Id = value; }

        public int TenantId { get; set; }
 
        //...
        [ForeignKey(nameof(Id))]
        public virtual ImmunizationRecord ImmunizationRecord { get; set; }      
    }

ImmunizationRecord - Only one per student allowed

[Table("tblImmunizationRecord")]
    public class ImmunizationRecord : FullAuditedEntity, IMustHaveTenant
    {
        public ImmunizationRecord()
        {
            ShotRecords = new HashSet<ShotRecord>();
        }

        [Key, ForeignKey(nameof(ShotRecords))]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public override int Id { get => base.Id; set => base.Id = value; }

        public int TenantId { get; set; }

        public int StudentId { get; set; }

       //...

        public virtual Student Student { get; set; }
        public virtual ICollection<ShotRecord> ShotRecords { get; set; }
    }

ShotRecord - there can be many shot records for each ImmunizationRecord

[Table("tblShotRecord")]
    public class ShotRecord : FullAuditedEntity, IMustHaveTenant
    {
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public override int Id { get => base.Id; set => base.Id = value; }

        public int ImmunizationRecordId { get; set; }

        public int TenantId { get; set; }

        //...

       public virtual ImmunizationRecord ImmunizationRecord  {get; set; }
    }

My DbContext

modelBuilder.Entity<Student>()
                        .HasOptional(s => s.ImmunizationRecord)
                        .WithRequired(z => z.Student);

            modelBuilder.Entity<ShotRecord>().HasRequired(r => r.ImmunizationRecord).WithMany(i => i.ShotRecord).HasForeignKey(l => l.ImmunizationRecordId).WillCascadeOnDelete(false);

Hello!

We'd love to use the AspNetZeroRadTool from within an ASP.NET MVC 5.x & jQuery project however we're having some issues.

I'm hoping this is coming over to the ASP.NET MVC 5.x projects as well.

--

I've copied over files but it seems that the Extension is hard coded to check for Core Project folders.

I also get the error: "No executable found matching command "dotnet-ef"

Please advise.

Thank you

Hello!,

I know that asp.net zero primarily focuses around code first migrations.

Is it at all possible to use a Database first ADO.NET Entity Data Model within asp.net zero?

if so, how would one go about making this happen?

Thank you!

Showing 1 to 5 of 5 entries