为什么设计师在从数据库更新模型时创建两个.Designer.cs文件? [英] Why is the designer creating two .Designer.cs files when updating model from database?
问题描述
我可以删除新的Model1.Designer.cs文件,但是新添加的字段不可用。
是否有解决方案(删除和重新创建模型除外)?
听起来你可能已经删除并重新创建了模型(或类似的东西),但是将原始设计器文件留在目录中。那么当你添加一个新的模型时,它必须使用Model1而不是Model作为设计器文件名。你尝试排除了Model.Designer.cs文件,并将它与Model1.Designer.cs文件相关联?
好的,看项目我们可以看到以下可能相关的部分:
< Compile Include = Domain\Model.Designer.vb>
< AutoGen> True< / AutoGen>
< DesignTime> True< / DesignTime>
< Dependent Upon> Model.edmx< / Dependent Upon>
< / Compile>
我相信这个告诉项目代码文件是项目的一部分,应该是一个文件model.edmx的子节点,并在更改时重新生成。
我们也有这个部分:
< EntityDeploy Include = Domain\Model.edmx >
< Generator> EntityModelCodeGenerator< / Generator>
< LastGenOutput> Model.Designer.vb< / LastGenOutput>
< CustomToolNamespace> Domain< / CustomToolNamespace>
< / EntityDeploy>
不知道这些控件中哪个控件生成的文件名,但是您可以尝试手工编辑项目文件看看它是否有所作为。我会说你需要同时改变,而不只是一个。
Like the question says: In Visual Studio, when in the Model.edmx, when I Update Model from Database... after adding a few new database fields, it's creating an almost duplicate Model1.Designer.cs file that is causing conflicts with the original Model.Designer.cs.
I can delete the new Model1.Designer.cs file, but then the newly added fields aren't available.
Is there a solution to this (other than deleting and recreating the model)?
It sounds like you might have deleted and recreated the model (or something similar) but left the original designer file in the directory. Then when you added a new model it had to use Model1 instead of Model as the designer file name. Have you tried excluding the Model.Designer.cs file and leaving it working with the Model1.Designer.cs file instead?
Okay, looking at the project file for a project of ours with a model in, I can see the following potentially relevant sections:
<Compile Include="Domain\Model.Designer.vb">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Model.edmx</DependentUpon>
</Compile>
I believe this one tells the project that the code file is part of the project, and should be a subnode of the file model.edmx, and be regenerated when it changes.
We also have this section:
<EntityDeploy Include="Domain\Model.edmx">
<Generator>EntityModelCodeGenerator</Generator>
<LastGenOutput>Model.Designer.vb</LastGenOutput>
<CustomToolNamespace>Domain</CustomToolNamespace>
</EntityDeploy>
Not sure which of these controls the generated file name, but you could try hand editing your project file to see if it makes a difference. I'd say you'd need to change both at the same time, rather than just one.
这篇关于为什么设计师在从数据库更新模型时创建两个.Designer.cs文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!