How to populate SQL Database from App Service

Stefan Novak 46 Reputation points
2022-12-14T11:59:19.49+00:00

Hello,

I'm sorry for what's going to be an extremely simple question I'm guessing. I've been having trouble finding the right docs for what I want.

My problem is that I have a .NET application that connects to a locally hosted SQL Server container. It works great.

For production, I deploy my application to App Service, and I've created a SQL Database in Azure that I want to be the production DB. In App Service, I've set the DefaultConnection to the connection string I've gotten from the Azure SQL Database.

I thought this would just work. However when I do requests, I get 500s, SQLExceptions, showing 'Invalid Column Names'. When I look at the tables in the SQL Database, there are none, it's empty.

How do I get the tables populated from my App Service? I've been doing a code first approach, so I don't want to have to create the tables by hand. Although maybe this is the way it's supposed to be done?

Thanks all

Azure SQL Database
{count} votes

Accepted answer
  1. Bjoern Peters 8,901 Reputation points
    2022-12-14T12:24:39.047+00:00

    Hi @Stefan Novak

    How do you connect to your local database? Using SQL Server Management Studio?

    In SSMS, you can just right-click on your database => Tasks => Generate Scripts.
    This will generate all the required statements for creating your database with all your table structure (maybe you only mark the structure with the database itself)

    270538-image.png

    https://learn.microsoft.com/en-us/sql/ssms/scripting/generate-and-publish-scripts-wizard?view=sql-server-ver16

    I hope my answer is helpful to you,

    Your
    Bjoern Peters

    If the reply was helpful, please upvote and/or accept it as an answer, as this helps others in the community with similar questions. Thanks!

    2 people found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.