daramasala
daramasala

Reputation: 3030

Azure Mobile Services - Local DB

I am developing a mobile service. When I run it locally, it uses a local db (I think it is Sql Server Express). When it runs on Azure, it uses an azure sql server instance.

Everything works fine but I don't want to put the local db mdf file into git (it's not really a part of the project - just a temp db for development purposes).

I want to have a script or a piece of code that will create the local database if it does not exist. This way, when a developer clones the project for the first time, she will run the script and it will create an empty mdf file. Db and schema creation will be taken care by the database initializer and the entity framework.

I'm new to MS technologies and I don't know where to start.

What should I use to write such a script? Power shell? And how do I create an empty mdf file?

Upvotes: 1

Views: 424

Answers (1)

mattchenderson
mattchenderson

Reputation: 1620

The .mdf file will actually be created automatically if one does not exist. You can see this in the connection string located in your Web.config.

<add name="MS_TableConnectionString" connectionString="Data Source=(localdb) ...

This connection string value gets overwritten when you publish to the cloud. Instead, the service will use a connections string configured in the portal.

So for your scenario, you just want to make sure that file isn't getting into your repo. You might look at creating a .gitignore file. You could create rule for ignoring all such files, with *.mdf

Upvotes: 1

Related Questions