gpt4 book ai didi

c# - 存在同名数据库,或无法打开指定文件,或位于 UNC 共享上。这是什么意思?

转载 作者:搜寻专家 更新时间:2023-10-30 20:30:45 25 4
gpt4 key购买 nike

我使用实体数据模型 (=.edmx) 的 PL、BL、DAl、BE 构建了一个 ASP.NET 项目,该模型是从位于我的 DAL 项目中的基于服务的数据库 (=.mdf) 生成的。

我确实将 connectionString 从 BE app.config 复制到 PL web.config

怎么了?为什么我会收到此错误:

System.Data.SqlClient.SqlException: An attempt to attach an auto-named database for file C:\Documents and Settings\user\שולחן העבודה\למידה אישית\Lev\Lev\App_Data\Midrasha.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.

我的代码逻辑是 PL->BL->DAL-> 尝试将新对象保存到数据库中。产生问题的代码行是:

public void AddFeedback(Feedback feed)
{
MidrashaEntities _context = new MidrashaEntities();
_context.Feedback.AddObject(feed);
_context.SaveChanges(); <-------throw the exception
}

Feedback 是我 DAL 的 SQL 中的一个表,我将其生成为对象实体。

最佳答案

我在连接字符串之前遇到了同样的错误,所以确保你有正确的连接字符串

关于c# - 存在同名数据库,或无法打开指定文件,或位于 UNC 共享上。这是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8978367/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com