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

No User found after running "Update-Database" #5408


User avatar
0
kumaran created

After fresh install and running Update-Database, i do not see any user in my local db. I do see all the tables created but no data including user table.

Here is my connection string. Server=(localdb)\MSSQLLocalDB;Initial Catalog=xxDb;Integrated Security=True;

I have tried this with demo application and it worked. This is not working only after i downloaded the premium code. Need help.


9 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team

    The application will automatically initialize the data when it starts. So start your website.

  • User Avatar
    0
    kumaran created

    Additional information on my error: I have disabled multi-tenant and also i see that the seedHelper.cs code is not getting called when i run the host. Also i see that the seed folder is under the Migration folder vs seed folder found under EntityFrameworkCore folder for demo sites.

  • User Avatar
    0
    kumaran created

    <cite>maliming: </cite> The application will automatically initialize the data when it starts. So start your website.

    Hi I ran the site but still not working and there are no data in the table. I still see the seed code is not getting called.

    I have the host running and when i run the angular site, i get internal error because there is no data.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    Do you have this line <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.EntityFrameworkCore/EntityFrameworkCore/DatabaseCheckHelper.cs#L37">https://github.com/aspnetzero/aspnet-ze ... per.cs#L37</a> in your DatabaseCheckHelper.cs class ? There was a similar bug but fixed.

  • User Avatar
    0
    kumaran created

    OK, this is what i found. I went back and enabled multi-tenant and then ran the host and the site, then it created the user data. But there is a new problem. I have 2 admin account now in my user table. One with shouldChangePasswordOnNextLogin = true and the other one is false. I dont know what's going on.

  • User Avatar
    0
    kumaran created

    additional difference in 2 admin rows. One had tenant id and one does not. Not this make sense that one of them is for the tenant. Now my only question is why do i have to enable multi-tenant to get the site working even if i dont want multi-tenant.

  • User Avatar
    0
    alper created
    Support Team

    I think it's normal. One is for the tenant, one is for the host. [attachment=0:t3wyk7ru]2admins.jpg[/attachment:t3wyk7ru]

  • User Avatar
    0
    ryancyq created
    Support Team

    Tested with aspnetzero 5.5.2 and I am able to reproduce the issue.

    1. Download new template
    2. dotnet ef update database
    3. Set Const.MultiTenancyEnabled = false
    4. Run Web.Host project

    SeedHostDb() will be skipped at <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.EntityFrameworkCore/EntityFrameworkCore/AbpZeroTemplateEntityFrameworkCoreModule.cs#L61">https://github.com/aspnetzero/aspnet-ze ... ule.cs#L61</a>

    Because DatabaseCheckHelper.Exist() return false

    As mentioned by @ismcagdas, the issue may be related to <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero-core/blob/dev/aspnet-core/src/MyCompanyName.AbpZeroTemplate.EntityFrameworkCore/EntityFrameworkCore/DatabaseCheckHelper.cs#L37">https://github.com/aspnetzero/aspnet-ze ... per.cs#L37</a>

    Also, I found that when DatabaseCheckHelper.Exist() open database connection, null multiTenancySide is passed into <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFrameworkCore/EntityFrameworkCore/Uow/UnitOfWorkExtensions.cs#L24">https://github.com/aspnetboilerplate/as ... ons.cs#L24</a>

    Subsequently, it is used in <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFrameworkCore/EntityFrameworkCore/Uow/EfCoreUnitOfWork.cs#L99">https://github.com/aspnetboilerplate/as ... ork.cs#L99</a> and <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.EntityFrameworkCore/EntityFrameworkCore/Uow/EfCoreUnitOfWork.cs#L107">https://github.com/aspnetboilerplate/as ... rk.cs#L107</a>

    Ultimately, when getting database connection at <a class="postlink" href="https://github.com/aspnetboilerplate/aspnetboilerplate/blob/dev/src/Abp.ZeroCore.EntityFrameworkCore/Zero/EntityFrameworkCore/DbPerTenantConnectionStringResolver.cs#L40">https://github.com/aspnetboilerplate/as ... ver.cs#L40</a>

    Since multiTenancySide is null and it will attempt to retrieve tenant database connection.

  • User Avatar
    0
    alper created
    Support Team

    thanks @ryancyq for the complete report.