Open Closed

Upgrade to v1.11.0 #1511


0
kythor created

Can you please give me more information how to upgrade my application to this new version? I have allready upgraded to packages using

get-project -all | get-package | ?{ $_.Id -like 'Abp*' } | update-package

but how about the new features like "Chat between users", or "password complexity". What is the best, easiest, fastest way to integrate these, without breaking or overwriting changes I have allready done for my custom solution?


19 Answer(s)
  • 0
    kythor created

    Updated SignalR and Angular.UI.Grid but getting

    TypeError: Cannot read property 'length' of undefined
    

    All Grids on the SPA do not work(no content) and saving settings does not work, "internal server error".

    Doing all this with MPA is no problem. What am I missing?

  • 0
    ismcagdas created
    Support Team

    Hi,

    Can you a screenshot of your developer console where you catch this error ? Maybe we can figure out why it happens.

  • 0
    kythor created

    screenshot attached.

    as you can see the users are returned correctly from /api/services/app/user/GetUsers

    looking further, the error is thrown under this section:

    /*
     AngularJS v1.5.6
     (c) 2010-2016 Google, Inc. http://angularjs.org
     License: MIT
    */
    

  • 0
    kythor created

    these are the errors I get when opening the Host SPA

  • 0
    ismcagdas created
    Support Team

    Hi,

    Does this error happens on your development machine when you are debugging with visual studio ?

    Can you try to debug your project and send a screenshot of the same error ? Because in your screenshot javascript files are bundled and minified, it's very hard to understand what the error is.

  • 0
    kythor created

    At this moment I'm trying to implement all the changes from the latest version, this could maybe solve the issue.

    But can you tell me how to upgrade the database with the new tables,... as described in "201606150821191_Added_Chat_And_Friendship_Entities" and the rest?

  • 0
    kythor created

    Now I'm also getting this when opening the backend app:

    The name 'AbpSession' does not exist in the current context

    @if (AbpSession.MultiTenancySide == MultiTenancySides.Host || IsFeatureEnabled(AppFeatures.ChatFeature))
    Line 76:         {
    Line 77:             <div data-ng-include="'~/App/common/views/layout/chatbar.cshtml'" data-ng-controller="common.views.layout.chatbar as vm">
    
    
    Source File: ...\App\common\views\layout\layout.cshtml    Line: 75
    
  • 0
    ismcagdas created
    Support Team

    Hi,

    Have you seen this forum post #1073 and included github issue <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/96">https://github.com/aspnetzero/aspnet-zero/issues/96</a>.

    It might give you an idea about how to upgrade to latest version with less problems.

  • 0
    kythor created

    I understand that it's not as straightforward as I first thougth, and merging all your changes in my project manually is actually a good thing, because I learn the structure of aspnetzero.

    However, some problems, still persist, even after copying all changed code or layout files.

    Most pressing issue now is why AbpSession is throwing an error? This is part of the Abp dll's, which I allready updated. Any help would be welcome.

  • 0
    ismcagdas created
    Support Team

    Hi,

    In order to use AbpSession in views, we define it in the [YourProjectName]WebViewPageBase class. It should have such a code to define it.

    public abstract class AbpZeroTemplateWebViewPageBase<TModel> : AbpWebViewPage<TModel>
    {
        public IAbpSession AbpSession { get; private set; }
        
        protected AbpZeroTemplateWebViewPageBase()
        {
            AbpSession = IocManager.Instance.Resolve<IAbpSession>();
            LocalizationSourceName = AbpZeroTemplateConsts.LocalizationSourceName;
        }
    }
    

    Can you compare it with your version ? If it is missing, you can add it to your ViewBase and solve the problem.

    I hope this helps.

  • 0
    ismcagdas created
    Support Team

    By the way, I know that it's a hard work to do. We will always try to help if you stack somewhere else during the update process :)

  • 0
    kythor created

    oops, my mistake, the code was missing indeed. It's working now, the Angular Grids are also working.

    Now I want to upgrade the database. I'm using the Packet Manager Console and the command Upgrade-Database. This is the result:

    Applying explicit migrations: [201606150821191_Added_Chat_And_Friendship_Entities, 201606161233356_Make_FriendShip_And_Chat_TenantId_Nullable, 201606220958138_Add_FriendUserName_To_Friendship_Table, 201606231022491_Add_TenancyName_And_ProfilePictureId_To_AppFriendships_Table, 201606240745029_Add_MayHaveTenant_Annotation_To_ChatMessage_And_Friendship, 201607211123175_Added_Validation_To_Chat_Entities].
    Applying explicit migration: 201606150821191_Added_Chat_And_Friendship_Entities.
    Applying explicit migration: 201606161233356_Make_FriendShip_And_Chat_TenantId_Nullable.
    Applying explicit migration: 201606220958138_Add_FriendUserName_To_Friendship_Table.
    Applying explicit migration: 201606231022491_Add_TenancyName_And_ProfilePictureId_To_AppFriendships_Table.
    Applying explicit migration: 201606240745029_Add_MayHaveTenant_Annotation_To_ChatMessage_And_Friendship.
    Applying explicit migration: 201607211123175_Added_Validation_To_Chat_Entities.
    Unable to update database to match the current model because there are pending changes and automatic migration is disabled. Either write the pending model changes to a code-based migration or enable automatic migration. Set DbMigrationsConfiguration.AutomaticMigrationsEnabled to true to enable automatic migration.
    You can use the Add-Migration command to write the pending model changes to a code-based migration.
    

    If I look at the database the tables are created correctly. But I'm confused with the last statement "Unable to update database to match the current model". What does this mean, what do I need to do?

    And now getting this error:

    The model backing the 'TIBtvDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
    
  • 0
    ismcagdas created
    Support Team

    Can you try to run "Add-Migration" command on the package manager console ? If you added migration classes to your project, this might be a problem.

    Instead of adding new migration classes to your project, use "Add-Migration" command to generate migrations of new version.

  • 0
    kythor created

    If I do Add-Migration it asks for "Name"? Is this like "201606150821191_Added_Chat_And_Friendship_Entities"? And what does it do exactly?

    I copied the new Chat and Friendship classes from the latest build source.

    I always used Database First in the past, so this is new stuff for me.

    Under \EntityFramework\Migrations\Configuration, AutomaticMigrationsEnabled is set to False. Would setting this to True help?

  • 0
    ismcagdas created
    Support Team

    Just give a random name like Add-Migration "Upgrade_To_AspNetZero_1.11", I want to see if it generates someting or just an empty migration class.

    If it does generates some migration code, then you should delete migrations you copied from AspNet Zero template (the ones about v1.11 for chat feature) and use only the new one generated by your Add-Migration code.

  • 0
    kythor created

    It generated:

    public partial class Upgrade_To_AspNetZero_111 : DbMigration
        {
            public override void Up()
            {
                DropTable("dbo.AppChatMessages",
                    removedAnnotations: new Dictionary<string, object>
                    {
                        { "DynamicFilter_ChatMessage_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    });
                DropTable("dbo.AppFriendships",
                    removedAnnotations: new Dictionary<string, object>
                    {
                        { "DynamicFilter_Friendship_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    });
            }
            
            public override void Down()
            {
                CreateTable(
                    "dbo.AppFriendships",
                    c => new
                        {
                            Id = c.Long(nullable: false, identity: true),
                            UserId = c.Long(nullable: false),
                            TenantId = c.Int(),
                            FriendUserId = c.Long(nullable: false),
                            FriendTenantId = c.Int(),
                            FriendUserName = c.String(nullable: false, maxLength: 32),
                            FriendTenancyName = c.String(),
                            FriendProfilePictureId = c.Guid(),
                            State = c.Int(nullable: false),
                            CreationTime = c.DateTime(nullable: false),
                        },
                    annotations: new Dictionary<string, object>
                    {
                        { "DynamicFilter_Friendship_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    })
                    .PrimaryKey(t => t.Id);
                
                CreateTable(
                    "dbo.AppChatMessages",
                    c => new
                        {
                            Id = c.Long(nullable: false, identity: true),
                            UserId = c.Long(nullable: false),
                            TenantId = c.Int(),
                            TargetUserId = c.Long(nullable: false),
                            TargetTenantId = c.Int(),
                            Message = c.String(nullable: false),
                            CreationTime = c.DateTime(nullable: false),
                            Side = c.Int(nullable: false),
                            ReadState = c.Int(nullable: false),
                        },
                    annotations: new Dictionary<string, object>
                    {
                        { "DynamicFilter_ChatMessage_MayHaveTenant", "EntityFramework.DynamicFilters.DynamicFilterDefinition" },
                    })
                    .PrimaryKey(t => t.Id);
                
            }
        }
    }
    

    After that I ran the command "Update-Database" and reloaded the site. Bingo, no more error.

    So in the future, I don't need the migration files you guys added?

  • 0
    ismcagdas created
    Support Team

    Hi,

    Yes, you dont need to add migration classes by yourself, you just need to run Add-Migration command.

    But there is a strange thing, your last migration drops tables related to chat feature. Were you able to run chat feature ? Are those tables (AppChatMessages and AppFriendships) exists in the database ?

  • 0
    kythor created

    Yeah, just noticed this, the tables are gone now. Logging into the backend app throws an error for the chat app.

    Should I run the Update-Database again?

  • 0
    ismcagdas created
    Support Team

    Have you added new entities (ChatMessage and Friendship) to your DbContext ? Because if they are in your dbContext, last added migration shouldn't delete those tables.