Adding a database to the App_Data folder
I recently just started learning .NET, and more specifically I've been playing around with the MVC framework quite a bit and loving it. I'm running into a bit of a frustrating problem though. I can't add a database to my App_Data folder.
I'm running SQL Server 2008 R2 on my machine. When I go to add a new database to the App_Data folder I get a message "Connections to SQL Server database files (.mdf) require SQL Server 2008 Express to be installed and running. I did a little poking around and found this blog post describing how to set up a regular SQL Server database with mvc3. (http://blogs.lessthandot.com/index.php/WebDev/ServerProgramming/开发者_JS百科ASPNET/setting-up-sql-server-with-asp-net-mvc)
That works just fine, but after I do that when I try to add the newly created database to the App_Data folder I simply get an "Access is denied." error. I'm the admin on my machine and I can access the database just fine using SQL Server Management Studio.
Anyone know what I'm doing wrong?
The App_Data
folder is only meant to be used with SQL Express, where it attaches the database "on-the-fly" using a feature called user-instance mode (see Connecting to SQL Server Express User Instances (ADO.NET)). I'm not exactly sure what you mean by "when I try to add the newly created database to the App_Data folder", but don't do that. Your database is being stored in SQL Server; there's no reason to try to put it inside your project.
精彩评论