Skip to main content
corrects typo and removes unnecessary comment to get the edit more than 6 characters
Source Link

Thank you for your concise explanation of this problem. I ran into this same issue yesterday. I still haven't found a permanent solution, but here is my current workaround.

I'm using the Database.EnsureCreated() function to create the database.

Set connection string to include 'AtachDBFilename=AttachDBFilename=' setting.

Server=(LocalDB)\\MSSQLLocalDB;Database=ExploreCalifornia;AttachDbFilename=.\\ExploreCalifornia.mdf;Trusted_Connection=True;MultipleActiveResultSets=true

Run the application. It will generate an error:

Cannot attach the file '.\ExploreCalifornia.mdf' as database 'ExploreCalifornia'.

but it will create the database.

After that, change the connection string and remove 'AtachDBFilename=AttachDBFilename='.

 Server=(localdb)\\MSSQLLocalDB;Database=ExploreCalifornia;Trusted_Connection=True;MultipleActiveResultSets=true

I ran the application again with no errors and tables were created.

Hope this helps!

Thank you for your concise explanation of this problem. I ran into this same issue yesterday. I still haven't found a permanent solution, but here is my current workaround.

I'm using the Database.EnsureCreated() function to create the database.

Set connection string to include 'AtachDBFilename=' setting.

Server=(LocalDB)\\MSSQLLocalDB;Database=ExploreCalifornia;AttachDbFilename=.\\ExploreCalifornia.mdf;Trusted_Connection=True;MultipleActiveResultSets=true

Run the application. It will generate an error:

Cannot attach the file '.\ExploreCalifornia.mdf' as database 'ExploreCalifornia'.

but it will create the database.

After that, change the connection string and remove 'AtachDBFilename='.

 Server=(localdb)\\MSSQLLocalDB;Database=ExploreCalifornia;Trusted_Connection=True;MultipleActiveResultSets=true

I ran the application again with no errors and tables were created.

Hope this helps!

Thank you for your concise explanation of this problem. I ran into this same issue yesterday. I still haven't found a permanent solution, but here is my current workaround.

I'm using the Database.EnsureCreated() function to create the database.

Set connection string to include 'AttachDBFilename=' setting.

Server=(LocalDB)\\MSSQLLocalDB;Database=ExploreCalifornia;AttachDbFilename=.\\ExploreCalifornia.mdf;Trusted_Connection=True;MultipleActiveResultSets=true

Run the application. It will generate an error:

Cannot attach the file '.\ExploreCalifornia.mdf' as database 'ExploreCalifornia'.

but it will create the database.

After that, change the connection string and remove 'AttachDBFilename='.

 Server=(localdb)\\MSSQLLocalDB;Database=ExploreCalifornia;Trusted_Connection=True;MultipleActiveResultSets=true

I ran the application again with no errors and tables were created.

Thank you for your concise explanation of this problem. I ran into this same issue yesterday. I still haven't found a permanent solution, but here is my current workaround.

I'm using the Database.EnsureCreated() function to create the database.

Set connection string to include 'AtachDBFilename=' setting.

"BlogDataContextAttach": "Server=(LocalDB)\MSSQLLocalDB;Database=ExploreCalifornia;AttachDbFilename=.\ExploreCalifornia.mdf;Trusted_Connection=True;MultipleActiveResultSets=true"

Server=(LocalDB)\\MSSQLLocalDB;Database=ExploreCalifornia;AttachDbFilename=.\\ExploreCalifornia.mdf;Trusted_Connection=True;MultipleActiveResultSets=true

Run the application. It will generate an error, " Message=Cannot attach the file '.\ExploreCalifornia.mdf' as database 'ExploreCalifornia'.",:

Cannot attach the file '.\ExploreCalifornia.mdf' as database 'ExploreCalifornia'.

but it will create the database.

After that, change the connection string and remove 'AtachDBFilename='.

"BlogDataContext": "Server=(localdb)\MSSQLLocalDB;Database=ExploreCalifornia;Trusted_Connection=True;MultipleActiveResultSets=true"

 Server=(localdb)\\MSSQLLocalDB;Database=ExploreCalifornia;Trusted_Connection=True;MultipleActiveResultSets=true

I ran the application again with no errors and tables were created.

Hope this helps!

Thank you for your concise explanation of this problem. I ran into this same issue yesterday. I still haven't found a permanent solution, but here is my current workaround.

I'm using the Database.EnsureCreated() function to create the database.

Set connection string to include 'AtachDBFilename=' setting.

"BlogDataContextAttach": "Server=(LocalDB)\MSSQLLocalDB;Database=ExploreCalifornia;AttachDbFilename=.\ExploreCalifornia.mdf;Trusted_Connection=True;MultipleActiveResultSets=true"

Run the application. It will generate an error, " Message=Cannot attach the file '.\ExploreCalifornia.mdf' as database 'ExploreCalifornia'.", but it will create the database.

After that, change the connection string and remove 'AtachDBFilename='.

"BlogDataContext": "Server=(localdb)\MSSQLLocalDB;Database=ExploreCalifornia;Trusted_Connection=True;MultipleActiveResultSets=true"

I ran the application again with no errors and tables were created.

Hope this helps!

Thank you for your concise explanation of this problem. I ran into this same issue yesterday. I still haven't found a permanent solution, but here is my current workaround.

I'm using the Database.EnsureCreated() function to create the database.

Set connection string to include 'AtachDBFilename=' setting.

Server=(LocalDB)\\MSSQLLocalDB;Database=ExploreCalifornia;AttachDbFilename=.\\ExploreCalifornia.mdf;Trusted_Connection=True;MultipleActiveResultSets=true

Run the application. It will generate an error:

Cannot attach the file '.\ExploreCalifornia.mdf' as database 'ExploreCalifornia'.

but it will create the database.

After that, change the connection string and remove 'AtachDBFilename='.

 Server=(localdb)\\MSSQLLocalDB;Database=ExploreCalifornia;Trusted_Connection=True;MultipleActiveResultSets=true

I ran the application again with no errors and tables were created.

Hope this helps!

Source Link

Thank you for your concise explanation of this problem. I ran into this same issue yesterday. I still haven't found a permanent solution, but here is my current workaround.

I'm using the Database.EnsureCreated() function to create the database.

Set connection string to include 'AtachDBFilename=' setting.

"BlogDataContextAttach": "Server=(LocalDB)\MSSQLLocalDB;Database=ExploreCalifornia;AttachDbFilename=.\ExploreCalifornia.mdf;Trusted_Connection=True;MultipleActiveResultSets=true"

Run the application. It will generate an error, " Message=Cannot attach the file '.\ExploreCalifornia.mdf' as database 'ExploreCalifornia'.", but it will create the database.

After that, change the connection string and remove 'AtachDBFilename='.

"BlogDataContext": "Server=(localdb)\MSSQLLocalDB;Database=ExploreCalifornia;Trusted_Connection=True;MultipleActiveResultSets=true"

I ran the application again with no errors and tables were created.

Hope this helps!