0

I'm reading a tutorial on MVC3 http://www.asp.net/mvc/tutorials/mvc-music-store-part-4. There is a code that goes to web.config :

<connectionStrings>
<add name="MusicStoreEntities"
connectionString="Data Source=|DataDirectory|MvcMusicStore.sdf"
providerName="System.Data.SqlServerCe.4.0"/>
</connectionStrings> 

Is it supposed to create an sdf file when the application is ran ? Cause it doesn't. I'm totally new to MVC3. Thanks!

0

1 Answer 1

3

I have read and completed the tutorial you are referring to and yes, the sdf (SQL Server Compact) file is supposed to be created when your first run the tutorial.

There could be a host of reasons why it is not being created for your but I'll address the two most common ones.

1) Platform requirements. Make sure you have installed SQL Server Compact runtime and tools SQL Server Compact 4.0 - including both runtime and tools support http://www.microsoft.com/web/gallery/install.aspx?appid=SQLCE;SQLCEVSTools_4_0

2) You've added the App_Data folder by Right Clicking on the site project and selecting 'Add ASP.NET Folder' -> App_Data

3) You wired up the database initializer in the Application_Start() method in the Global.asax.cs by adding the following line

protected void Application_Start()
{
    System.Data.Entity.Database.SetInitializer(
            new MvcMusicStore.Models.SampleData());
    //... other lines follow

Make sure you follow the steps carefully in Step 4 - http://www.asp.net/mvc/tutorials/mvc-music-store-part-4

Let me know if this helps

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

6 Comments

I followed the tutorial and got the SDF file, so I'm inclined to think that jdmonty is right - one of these 3 issues is the problem.
Actually, I just thought of a 4th possible scenario - even after the SDF file is created, it doesn't show up in Visual Studio. If that's your evidence that it's not being created, go look in the folder.
Click the button at the top of the solution explorer that shows all files in the physical folder, if the SDF is there, then you just need to right click on the file and select include in solution.
I did install both tools mentioned. The App_Data folder is there and all the code it carefully copied from the tutorial. The application works as described in tutorial but the sdf file is not created. I made sure VS2010 shows All Files in the solution and search in the solution folder as well. The file was is not created.
@Chuchelo - strange, could be a permissions issue, could you try running Visual Studio as Administrator and see if that clears it up.
|

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.