2

When I surf to the deployed web app on azure, and I want to save e.g. a comment or a post to this blog project, I get error message that I can't save into the db which I have on azure. Yet, I have transformed the connection string to point to the right db on azure in my web.release.config, and I can see data from the db too, when I search for a blog or a post on this web app, data is displayed from the db on azure.

But again, I can not save any data to that db from the web app. So when I want to create a new comment or blog, I can not do that and I get something like:

Cannot insert the value NULL into column 'Id', table 'Blog.dbo.Comments'; column does not allow nulls. INSERT fails.

Yet, I can create a blog or comment locally and it works just fine, but that is to the local db.

kryman
  • 33
  • 9

1 Answers1

1

Probably you don't set the Id in your code and on your localhost you have some king of auto increment on the Id field in your DB ( Auto increment primary key in SQL Server Management Studio 2012 ), but you don't have that in your Azure SQL, so it won't generate it for you automatically, so it will be null, but probably it is set to non nullable, and this is why you get the error message. If you change it like you can see in the link above, it should work.

hujtomi
  • 1,540
  • 2
  • 17
  • 23