2

I have a ASP.NET Web application, which serves as a backend web api for my Android application.

Now just for development purpose, I am using SmarterAsp.net's free trial hosting. And I have successfully published the web app to the server using Visual Studio 2015 (CE) built in publish tool.

However I now need to setup the MS SQL database on the server as well, which requires SQL files to run from.

How would I generate the SQL files that are needed for my project? I am using Entity Framework and used Code First Migration that automatically setup my local SQL Server.

It would be preferable if there is a way to do this in VS without having to open up SQL Server and export the sql files. Thanks!

1 Answer 1

3

You can do that easily with code first migrations. If you already have migrations enabled, just go to the package manager console and create an idempotent script:

Update-Database -Script -SourceMigration: $InitialDatabase

This will create a script of all your database objects. If you don't have migrations enabled, then it is fairly easy to configure from the console:

Enable-Migrations
Add-Migration InitialSnapshot -IgnoreChanges
Update-Database -Script -SourceMigration: $InitialDatabase

https://msdn.microsoft.com/en-us/data/jj591621.aspx?f=255&MSPPError=-2147217396#enabling

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.