1

I am new to ASP.NET MVC. While going through this tutorial https://learn.microsoft.com/en-us/aspnet/mvc/overview/getting-started/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

I am getting error

CREATE FILE encountered operating system error 123 (the filename, directory name, or volume label syntax is incorrect.) while attempting to open or create the physical file 'C:\Users\AMIT & AKASH\ContosoUniversity2 AttachDBFilename=|DataDirectory|_ContosoUniversity2.mdf.mdf'.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.

My connection string

<connectionStrings>
    <add name="SchoolContext" 
         connectionString="Data Source=(LocalDb)\v12.0;Initial Catalog=ContosoUniversity2 AttachDBFilename=|DataDirectory|\ContosoUniversity2.mdf;Integrated Security=SSPI;" 
         providerName="System.Data.SqlClient" />
</connectionStrings>

SchoolInitializer.cs

enter image description here

StudentContext.cs

enter image description here

2
  • 1
    Don't post code as images, we prefer text that can be googled. Commented Dec 24, 2017 at 8:42
  • next time for sure on my mind :-) Commented Dec 24, 2017 at 9:49

1 Answer 1

1

You most likely just forgot a semicolon after specifying the initial catalog:

<connectionStrings>
    <add name="SchoolContext" 
         connectionString="Data Source=(LocalDb)\v12.0;Initial Catalog=ContosoUniversity2;AttachDBFilename=|DataDirectory|\ContosoUniversity2.mdf;Integrated Security=SSPI;" 
         providerName="System.Data.SqlClient" />
</connectionStrings>

So change:

Initial Catalog=ContosoUniversity2

to

Initial Catalog=ContosoUniversity2;
                                  ^
                                  |
                     add this semicolon!
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.