edmx 重新构建会创建重复的设计器 cs 文件

发布于 2025-01-07 10:22:14 字数 156 浏览 0 评论 0原文

因此,使用我的 edmx (MyDatabase.Edmx) 文件,每当我从数据库更新模型并重建项目时,它都会创建一个重复的设计器文件 (MyDatabase1.Designer.cs)。想知道是否有人知道配置文件以避免创建重复文件?出于开发目的,它发生在我的本地,我的其他队友没有遇到同样的问题。

So, with my edmx (MyDatabase.Edmx) file, whenever I update model from database and I rebuild the project, it creates a duplicate designer file (MyDatabase1.Designer.cs). Was wondering if anyone knows of a config file to avoid creating the duplicate file? It happens on my local for dev purposes, my other teammates doesn't get the same issue.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

梦里兽 2025-01-14 10:22:15

我知道这是一个老问题,但我面临着同样的问题并找到了如何正确解决它。如果您查看包含 .edmx 文件的项目文件内部(因此在任何文本编辑器中打开 .csproj 文件),您将看到多次出现 .Designer.cs 文件名(在您的情况下为 MyDatabase1.Designer.cs )。将它们更改为 MyDatabase.Designer.cs 并将 MyDatabase1.Designer.cs 文件重命名为 MyDatabase.Designer.cs 以解决问题。

I know this is an old question but I was facing the same problem and found how to resolve it properly. If you look inside the project file containing your .edmx file (so open the .csproj file in any text editor) you'll see many occurrences of the .Designer.cs file name (MyDatabase1.Designer.cs in your case). Change them to MyDatabase.Designer.cs and rename MyDatabase1.Designer.cs file to MyDatabase.Designer.cs to fix the problem.

浪漫人生路 2025-01-14 10:22:15

看起来您已将 MyDatabase.Designer.cs 作为常规源文件包含在项目中。只需排除它,删除 MyDatabase1.Designer.cs 并重建项目即可。

Looks like you have MyDatabase.Designer.cs included in your project as a regular source file. Just exclude it, delete MyDatabase1.Designer.cs and rebuild the project.

骄傲 2025-01-14 10:22:15

所以我的方法是从 TFS 中查看 edmx 文件,然后刷新表。重建项目,然后重建解决方案。
由于某种原因它停止复制文件。

So the way I did it is to check out the edmx files from TFS and then refreshed the tables. Rebuild the the project and then rebuild teh solution.
For some reason it stopped duplicating the file.

始终不够爱げ你 2025-01-14 10:22:15

以下问题/答案提供了有关当前问题的详细信息。当我面临同样的问题时,我偶然发现了这个答案。

为什么是设计器从数据库更新模型时创建两个 .Designer.cs 文件?

简而言之,您需要通过 xml 编辑器调整 .csproj 文件,并通过编辑新文件名(即 MyDatabase1.Designer.cs)返回到 MyDatabase.Designer.cs

The following question/answers provide good detail on the issue at hand. I stumbled across this answer as I was facing the same issue.

Why is the designer creating two .Designer.cs files when updating model from database?

In a nutshell you need to adjust your .csproj file via an xml editor and adjusting any node (2 to 3) by editing the new file name (i.e. MyDatabase1.Designer.cs) back to MyDatabase.Designer.cs

幼儿园老大 2025-01-14 10:22:15

只需从 .CSproj 文件中删除此行:

<Compile Include="Models\Model2.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Model.edmx</DependentUpon>
</Compile>

然后在同一文件中将 Model2.Designer 替换为 Model.Designer

just remove this lines from .CSproj file:

<Compile Include="Models\Model2.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Model.edmx</DependentUpon>
</Compile>

and then replace Model2.Designer to Model.Designer in same file

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文