- WebConfig文件里添加数据库链接字符:
<add name="MovieDBContext(可以自己取字符串名字)" connectionString="Data Source=(LocalDB)v11.0; AttachDbFilename=|DataDirectory|Movies.mdf;Integrated Security=True" providerName="System.Data.SqlClient"/>
如果忘了添加,会报错如下:
CREATE DATABASE permission denied in database 'master'.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.SqlClient.SqlException: CREATE DATABASE permission denied in database 'master'.
Source Error:
Line 19: public ActionResult Index()
Line 20: {
Line 21: return View(db.Movies.ToList());
Line 22: }
Line 23:
|
Source File: d:My Programming LearnedVS2012MvcMovieMvcMovieControllersMoviesController.cs Line: 21
2.