[英]System.Data.SqlClient.SqlException: 'Cannot drop database . How to resolve?
I have added a property "password" in my class model User. 我在类模型User中添加了属性“ password”。 It's showing in my view
Register.cshtml
now. 它现在显示在我的视图
Register.cshtml
。
<form action="~/Users/SaveRegister" method="post">
@Html.ValidationSummary(true)
@Html.AntiForgeryToken()
<div class="editor-label">
@Html.LabelFor(model => model.user_name)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.user_name)
@Html.ValidationMessageFor(model => model.user_name)
</div>
<div class="editor-label">
@Html.LabelFor(model => model.password)
</div>
<div class="editor-field">
@Html.EditorFor(model => model.password)
@Html.ValidationMessageFor(model => model.password)
</div>
<p>
<input type="submit" value="Register" />
</p>
</form>
But it's giving the exception in my controller db.Users.Add(User);
但是它在我的控制器
db.Users.Add(User);
给出了异常db.Users.Add(User);
when I press Register
. 当我按
Register
。
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult SaveRegister(Airlineapp.Models.User User, HttpPostedFileBase file)
{
db.Users.Add(User);
db.SaveChanges();
return RedirectToAction("Index");
}
Someone connected to the database. 有人连接到数据库。 Try to switch to another database and then, to drop it:
尝试切换到另一个数据库,然后将其删除:
Try 尝试
SP_WHO
to see who connected SP_WHO
看谁连接了
and KILL
if needed or use using (context db = new context())
并在需要时使用
KILL
或使用using (context db = new context())
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.