1

When publishing my first ASP.NET Core 2.1 web app in Azure from Visual Studio 2017, I am setting up EF migrations like in the picture below:

PICTURE

After running Publish, the identity table is not created. In Configure -> Settings I have info, that No databases found in the project.

Also I am using console command:

dotnet ef database update --context AppIdentityDbContext

What gives me same result. Connection strings I am taking from Azure Show database connection strings, updateting them with username and password.

I am not sure what I am doing wrong here. Everything works perfectly on my computer. I will be thankful for any suggestions to check.

Right now, after trying to populate Identity table: public static class IdentitySeedData

 {
        private const string adminUser = "****";
        private const string adminPassword = "****";
        public static async Task EnsurePopulated(UserManager<IdentityUser> userManager)
        {
            IdentityUser user = await userManager.FindByIdAsync(adminUser);
            if (user == null)
            {
                user = new IdentityUser("Admin");
                await userManager.CreateAsync(user, adminPassword);
            }
        }
    }

I am getting error:

AggregateException: One or more errors occurred. (Invalid object name 'AspNetUsers'.)

System.Threading.Tasks.Task.ThrowIfExceptional(bool includeTaskCanceledExceptions)
SqlException: Invalid object name 'AspNetUsers'.

System.Data.SqlClient.SqlCommand+<>c.<ExecuteDbDataReaderAsync>b__108_0(Task<SqlDataReader> result)

UPDATE: I found out, that my problem occurs only identity database.

  • Do you have a database to put the tables in? (Informational message says "No databases found in the project".) Also, you might not be able to use "Admin" as a username in Azure SQL. – Mike Sherrill 'Cat Recall' Aug 21 '18 at 10:45
  • @MikeSherrill'CatRecall' yes, I was trying to seed empty table with Admin's login and password. I am still learning Azure, and I managed to find tables for other bases, but only identity base is not migrated. –  Aug 21 '18 at 16:34
  • As I did not managed to migrate my Identity database to Azure, I found alternative solution here: https://stackoverflow.com/questions/38040976/invalid-object-name-dbo-aspnetusers-in-asp-net-mvc-5-entity-framework Anyway, thanks for effort guys. –  Aug 21 '18 at 21:10

1 Answers1

0

As I did not managed to migrate my Identity database to Azure, I found alternative solution here: Invalid object name 'dbo.AspNetUsers' in Asp.NET MVC 5 Entity Framework