Visual Studio 2012-无法移动EF .tt文件 [英] Visual Studio 2012 - Can't move EF .tt files

查看:109
本文介绍了Visual Studio 2012-无法移动EF .tt文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在VS2012中注意到,当您创建新的EF模型(.edmx)时,DbContext是默认代码生成,.tt(T4模板)文件现在嵌套在.edmx下面

I noticed in VS2012 that when you make a new EF Model (.edmx) that the DbContext is the default code generation and the .tt (T4 template) files are now nested underneath the .edmx file in the Solution Explorer.

问题: 是否可以将这些.tt文件移动到另一个文件夹或项目?当我尝试在解决方案资源管理器中拖放时,它不允许我移动嵌套的.tt文件。

Question: Is there a way to move these .tt files to another folder or project? When I try to drag and drop in Solution Explorer, it won't allow me to move the nested .tt file.

问题详细信息:以前(在VS2010中),我曾经将POCO的一个.tt文件移到名为DataDefinitions的类库中,而另一个.tt文件则留在上下文中的DataAccess类中。现在看来我将无法移动这些文件...并将我的资产分成不同的层。

Problem details: Previously (in VS2010) I used to move the one .tt file for my POCOs into a class library called DataDefinitions and I left the other .tt file for my context in a class library called DataAccess. Now it seems like I won't be able to move these files... and separate out my assets into different layers.

在此MSDN文章中,如果滚动到在底部,您可以看到现在如何嵌套.tt文件的图片...
http: //msdn.microsoft.com/zh-cn/data/jj613116

In this MSDN article, if you scroll to the bottom, you can see a picture of how the .tt files are now nested... http://msdn.microsoft.com/en-us/data/jj613116

推荐答案

这是一个奇怪的新功能将模板作为依赖项添加到EDMX文件的位置。您可以通过编辑项目的.csproj文件来修复它(可以在记事本中完成,也可以在VS中卸载项目并进行编辑)。您会发现类似这样的东西:

It is some strange new feature where templates are added as dependency to EDMX file. You can fix it by editing .csproj file for your project (you can do it in notepad or unload project in VS and edit it). You will find something like this:

<None Include="Model.tt">
  <Generator>TextTemplatingFileGenerator</Generator>
  <DependentUpon>Model.edmx</DependentUpon>
  <LastGenOutput>Model.cs</LastGenOutput>
</None>

您只需要删除 DependentUpon 元素,然后模板项将成为项目的独立部分。

You just need to remove DependentUpon element and the template item will become independent part of the project.

这篇关于Visual Studio 2012-无法移动EF .tt文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆