I’m trying to call a stored procedure from my MVC app using EntLib 5.0. Here’s my connection string (for SQL Server 2008):
Server=local;Database=Test;Trusted_Connection=True
I’m getting this error:
An attempt to attach an auto-named database for file
C:\dev\pestsApp_Data\aspnetdb.mdf failed. A database with
the same name exists, or specified file cannot be opened,
or it is located on UNC share.
Why is EntLib looking in my source code directory instead of in the directory where my database is located (the default location)? Here is the actual location of my database:
C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA
How do I make EntLib connect to that database?
In your web.config you’ll have to put a in the beginning of your Connectionstrings section.
If you don’t, your application will inherit the connectionstrings that are defined in the root web.config by default.
So:
This issue is not related to EntLib 5.0.
Perhaps a typo?
C:\dev\pestsApp_Data\aspnetdb.mdf => C:\dev\pests\App_Data\aspnetdb.mdf
And your application can access C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\DATA? By default it could not.