问题描述:

I am currently working on an ASP.Net MVC 3 tutorial on the MS ASP.Net website (MvcMusicStore). I use a database-first approach and have successfully modified the tutorial to access an independently created database through the Entity Framework instead of using the new EF 4.1 code-first approach, which is used in the tutorial. I use SQL Server 2008 R2 Developer Edition on my local machine.

The tutorial starts with an empty MVC website. The tutorial instructs on how to configure the website for the SQL provider through which user name and password registration occurs. I have been unable to get the provider to work. I actually created another separate MVC website with an account controller, and tried to register the provider through it (no code changes) and encountered the same problem. Obviously, cutting and pasting the relevant parts of the web config file from this second project into the empty tutorial did not fix the problem. I have been able to register and create an aspnetdb in SQL Server using aspnet_regsql. But my attempts to configure or access it have not worked. I have tried aspnet_regsql -A all -E, which gives me an error message. I have tried selecting the provider using the ASP.Net configuration tool that appears in the icon tray of the Solution Explorer in VS 2010. Have not been able to fix the problem.

Can anyone direct me to a solution to the problem? Is it simply the connection string? What am I missing?

网友答案:

If you did not change any of the provider elements in the default MVC3 web.config, then you need to change the ApplicationServices connection string near the top of web.config to use the information to connect to your SQL Server aspnetdb database.

相关阅读:
Top