3

I am trying to pick up ASP.Net - and following the mvc tutorial: http://www.asp.net/mvc/tutorials/mvc-music-store-part-4 (Note: I am totally new to the .Net framework, both C# and ASP.Net)

At the beginning the tutorial suggested to use SQL Server Compact 4.0 - But, I got the SQL Server Express installed instead (since I will be using it after, not just for the tutorial). I had another question that's been resolved about setting up the db Connection: ASP.Net SQL ConnectionStrings config

Now, obviously the database is empty - the tutorial didnt even say about instantiating the database, other than downloading some asset file for the db "SampeData.cs", and add it to the Global.asax.cs Application_Start method:

System.Data.Entity.Database.SetInitializer(new MvcMusicStore.Models.SampleData());

So I got the DB connected, but now I am getting:

Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.

When I put on debug point - Sometimes the Application_Start method is hit, sometimes it doesnt. However, I never see the Seed method in SampleData.cs ever being hit - so seems to me my problem right now is with seeding the db

1 Answer 1

1

Answering my own question here, hopefully this can help:

  1. Make sure you dont have the database already created
  2. Here is the connection String in Web.config:

    < add name="MusicStoreEntities" connectionString="Data Source=DB_NAME;Initial Catalog=MvcMusicStore;Integrated Security=SSPI" providerName="System.Data.SqlClient" />

And now it works and I can move on in my tutorial

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.