2

I am getting the following error here: http://mvcbense.azurewebsites.net/

Invalid object name 'dbo.BlogPosts'.

This is an MVC3 application using Entity Framework Code First. I have looked elsewhere and have only found something about changing the schema which I assume is what dbo. is.

I am fairly new to EF, but it would look as if EF creates these for me, so I am unsure of what to do. Looking in my local SQL Server Express, all the tables have the dbo. schema on them. Why would I be able to run them locally but not published to Azure?

Thanks

AvkashChauhan
  • 20,495
  • 3
  • 34
  • 65
  • 1
    do you have a table called dbo.BlogPosts? Can you post your code? – Taryn Jun 22 '12 at 19:11
  • @bluefeet What exactly would you like to see? The table is created dynamically, and yes that table exists locally in SQL Express after I run the application for the first time. –  Jun 22 '12 at 20:02

3 Answers3

1

The problem is that you haven't configured SQL Azure correctly to migrate your SQL Express based schema first. When you create an ASP.NET Windows Azure Website which is based on local SQL Server, you would have to manually migrate the on-premise DB configured to SQL Azure first and then publish your ASP.NET application to Windows Azure Website. IF you will not do it, your ASP.NET website will not work.

Based on the exception the initial DB tables are missing so what is needed for you is to select any of the suitable database migration method from the list below to migrate your DB first and then run your Windows Azure Website:

Migrating Databases to Windows Azure SQL Database (formerly SQL Azure)

AvkashChauhan
  • 20,495
  • 3
  • 34
  • 65
  • Exactly what I needed. Thank you so much! Do you know how to correctly get the default roles DB integrated correctly? "Could not find stored procedure 'dbo.aspnet_CheckSchemaVersion'." Seems to be answered here: http://stackoverflow.com/questions/2165908/could-not-find-stored-procedure-dbo-aspnet-checkschemaversion but I don't have any experience with aspnet_regsql.exe at all. –  Jun 24 '12 at 19:38
0

A much simpler solution suggested by Stan over here works: http://social.msdn.microsoft.com/Forums/windowsazure/en-US/9c20a99c-80c9-4b1d-afa4-26b9b418f435/connect-to-sql-azure-via-sql-server-management-studio-failed

Excerpt:

  1. cancel out of the first connection dialog that pops up.
  2. click on the New Query button from the toolbar (upper left)
  3. entered Server name: full servername Login: just the username (no @...)
  4. Under Options, Connect to Database, I typed TestDb1
  5. Hit connect.
Gautam Jain
  • 6,789
  • 10
  • 48
  • 67
0

I also experienced the same issue but while using Database first approach. Connection string in my service's/service's host web.config was incorrect. I changed the connection string and it worked.

Wasif Subzwari
  • 199
  • 3
  • 13