Base solution for your next web application

Activities of "mikemey01"

Nevermind - I figured it out. For anyone else that comes across this, this is what my custom repository looks like in order to get access to the DbContext:

public class PMRenderLeaseAgreementRepository : PropertyMentsRepositoryBase<PMRenderLeaseAgreement>, IPMRenderLeaseAgreementRepository
    {

        public PMRenderLeaseAgreementRepository(IDbContextProvider<PropertyMentsDbContext> dbContextProvider) : base(dbContextProvider)
        {

        }

        public void ExecuteStoredProcedure(string query, params object[] parameters)
        {
            Context.Database.ExecuteSqlCommand(query, parameters);
        }
    }

Also, follow the ABP documentation to put the interface in the .Core project so you can inject it in any of the services. I put the repository class in the EntityFrameworkCore project.

I got this working where I can now include the AbpUsers table for any AuditedEntity by adding a FK to either CreatorUserId, DeleterUserId, or LastModifierUserId.

Table with CreatorUserId, note that it references Authorization.Users.User instead of subclassing the AbpUsers entity:

[Table("PMNotes")]
    public class PMNotes : FullAuditedEntity, IMustHaveTenant
    {
        public virtual int TenantId { get; set; }
        
         ...

        [ForeignKey("CreatorUserId")]
        public Authorization.Users.User CreatorUser { get; set; }
    }

Added the collection to the Authorization.Users.User table:

public class User : AbpUser<User>
    {
        public ICollection<PMNotes> CreatorNotes { get; set; }
        ...
     }

Then in the DBContext, add the following (although this may not actually be required with the "ForeignKey" attribute above:

modelBuilder.Entity<PMNotes>()
                        .HasOne(m => m.CreatorUser)
                        .WithMany(t => t.CreatorNotes)
                        .HasForeignKey(m => m.CreatorUserId)
                        .OnDelete(DeleteBehavior.Restrict);

Hope it helps someone.

That breaks the app service:

private readonly IRepository<PMNotes> _notesRepository;

with the error:

The type ...PMNotes can not be used as a type parameter 'TEntity' in the generic type or method IRepository<TEntity>.

what is the manual configuration look like?

Hi - unfortunately not, I get the following error:

Unable to determine the relationship represented by navigation property 'User.DeleterUser' of type 'User'. Either manually configure the relationship, or ignore this property from the model.

For reference here is what I'm using:

I'm subclassing AbpUsers<User> and using the InverseProperty attribute:

public class User : AbpUser<User>
    {
        [InverseProperty("CreatorUser")]
        public ICollection<PMNotes> CreatorNotes { get; set; }
        [InverseProperty("DeleterUser")]
        public ICollection<PMNotes> DeleterNotes { get; set; }
        
    }

then in the table that I want to reference I'm doing:

[Table("PMNotes")]
    public class PMNotes : FullAuditedEntity, IMustHaveTenant
    {
        public virtual int TenantId { get; set; }

        public virtual User CreatorUser { get; set; }
        public virtual User DeleterUser { get; set; }
        
        [Required]
        public virtual string Note { get; set; }
    }

but i get this error:

Unable to determine the relationship represented by navigation property 'User.DeleterUser' of type 'User'. Either manually configure the relationship, or ignore this property from the model.

Please ignore - this fixed it:

#2293@9ffc4296-7fbc-4024-a143-0c9b2d107e2c

Makes sense - I'll start again with v4.0 of the .net core/jquery solution and hopefully standardize on that going forward. It seems like v3.2 was caught in a weird in-between area as EFCore wasn't being used and it was relying on project.json project format. It seems like aspnet zero is standardizing on EFCore's ability to use the PM migrations as opposed to CLI migrations seeing that the step-by-step guide was updated to remove the CLI instructions. Hopefully that remains the route for some time to come.

Is there anyway to version control the guides with the specific releases so they remain available? They're very handy references but difficult to follow as they change with the new version releases.

What version did you start with? I'm having similar issues converting version 3.2 to work with VS2017 (project.json - .csproj files) and getting EF to work. the CLI tool commands seem to no longer work with VS2017 projects and the package manager "Update-Database" don't work either.

Did you update all 20 or so ABP packages? Or selectively update only a few?

Hi - I'm using .NET Core/jQuery version 3.2 with .NET 4.6.1 framework.

Originally the project was using the project.json method in visual studio 2015. Migrations were handled with CLI tool using dotnet ef..

When I upgraded to visual studio 2017 it convert the project to .csproj files which broke the CLI tooling. However the package manager console does not work either. Note that this version does not use entityframeworkCore, instead it uses EF6 still.

I'm wondering if it would be best to cut my losses and download version 4.0 of .net zero and copy my code into that project. If that's the best route - is v4.0 a stable version? If I build a lot of code into this version I don't want to have to do this exercise every few months.

Thanks.

I think the issue I was running into is that it was inserting the tenantId of 1 into the PbPersons table from the seed class before the Default tenant was inserted into the AbpTenants table giving a FK reference error. I'm looking at the process order I setup now, either way seems to be fixed.

Thanks,

Mike

Showing 1 to 10 of 13 entries