0

Am trying to follow this link http://www.asp.net/mvc/tutorials/getting-started-with-aspnet-mvc3/cs/accessing-your-model%27s-data-from-a-controller to get started.

While creating Entity using code First approach , how can i create .mdf in VS. What should be my connection string ?

my connectionstring

<add name="MovieDBContext"
        connectionString="Data Source=|DataDirectory|Movies.mdf"
        providerName="System.Data.EntityClient"/>

Am getting error in DataSource while creating controller. wat should the Data Source for .MDF ?

1 Answer 1

1

If you're trying to use LocalDb (i.e. mdf)

  • The providerName needs to be "System.Data.SqlClient" for a start.
  • Then your connection string needs a bit more info, like this:

    "Data Source=(LocalDb)\v11.0;Initial Catalog=yourDbName;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\Movies.mdf"

If you wantng to use SqlServerCe (sdf) then:

  • The providerName needs to be "System.Data.SqlServerCe.4.0"
  • connection string:

    "Data Source=|DataDirectory|Movies.sdf"

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.