0

I have mvc application. I'm using code first approach. When new tenant registers to system i create new database with azure sql fluent api.

Database is created without problem but it's empty as expected. To initialize data from my migration i call myDB.Database.Initialize(true); it passes without any error but tables are not created.

To be sure i run project in my local computer and point connection string to azure database after running myDB.Database.Initialize(true); database is initialized.

I researched on internet people points to timeout issue for applying migration.Even i don't have any timeout issue extended timeout for migration but still same.

It creates table when i run from my computer (connected to azure db) but doesn't create when running on azure even i don't see any error.

Any idea why it's not creating on azure sql database ?

Tried to change timeout for migration configuration.

7
  • Check migrantion table if that exists and anything in there. Does the user you use to connect to the db has dbo access? Do you get any error? Commented Jul 13, 2019 at 17:55
  • Hello, When table is created its blank without any table. As i know it should be filled with talbes based on migration configuration files and database context. it does when i run from local without any problem. by local i mean i run visual studio but connection is pointed to azure sql database Commented Jul 13, 2019 at 18:10
  • Have you tried these steps? Commented Jul 14, 2019 at 16:07
  • When you run local with connection pointed to azure sql, it is same as on azure. Commented Jul 15, 2019 at 2:49
  • 1
    Thanks eveyone for help. I solved my problem with following thead. I think my problem was because my applications is multi tenant. i connect to database with connection string dynamicly. Each tenant connects to his/her database via connection string dynamicly. So connection strings was not in my webconfig. That's why i needed to specify connection string. And above thread is exactly about that. I implemented that code and it worked. stackoverflow.com/questions/14710758/… Commented Jul 15, 2019 at 17:16

1 Answer 1

1

According to @Cozdemir's comment:

I solved my problem with following thead. I think my problem was because my applications is multi tenant. i connect to database with connection string dynamicly. Each tenant connects to his/her database via connection string dynamicly. So connection strings was not in my webconfig. That's why i needed to specify connection string. And above thread is exactly about that. I implemented that code and it worked. Reference: EF Code First MigrateDatabaseToLatestVersion accepts connection string Name from config

I posted this as answer and this can be beneficial to other community members.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.