0

I am using the code first method in my windows azure project. I would like to see wich tables are created by the framework but the mdf file is not listed in the app_data folder. I tried editing the default connection string to:

<add name="ModelContext" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|ModelContext.mdf;User Instance=true;Database=ModelContext"
  providerName="System.Data.SqlClient" />

When using this connection string I get the following error:

CREATE FILE encountered operating system error 5(failed to retrieve text for this error. Reason: 15105) while attempting to open or create the physical file 'C:\Users\Myname\WindowsAzureProject1\MvcWebRole1\App_Data\ModelContext.mdf'. CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

How can I solve this?

Any help is greatly appreciated.

3
  • Does the web application work on its own outside of the web role? Are you using MVC, asp.net? Commented Feb 29, 2012 at 1:21
  • The application works when I use the default connection string. I am using MVC 3. Commented Feb 29, 2012 at 1:37
  • 1
    I've never used the Code First of EF, but if you wanted to put your database file in the App_Data folder that might not be a good solution. Windows Azure might move your application from one VM to another. If so, all files generated after deployment would be lost, which means your database file will be cleared, as well. Not sure if it's possible that EF Code First works with SQL Azure/SQL Server. Commented Feb 29, 2012 at 2:09

2 Answers 2

1

This isn't the best way to do things. It is probably a permission problem. Take a look at this:

http://www.windowsazure.com/en-us/develop/net/tutorials/web-app-with-sql-azure/

It uses code first and works with Azure and starts out using SQL Express.

Sign up to request clarification or add additional context in comments.

Comments

0

Sql Express is not installed in a web role. You need to use a Sql Azure database or add a start up task for the web role to install sql express. Take a look at this post from Steve Marx http://blog.smarx.com/posts/introduction-to-windows-azure-startup-tasks on how to add a start up task

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.