3

我按照下一个链接的模板预先生成了视图:

http://blogs.msdn.com/b/adonet/archive/2008/06/20/how-to-use-a-t4-template-for-view-generation.aspx

我需要改进到 Entity Framework 5.0,但如果我将架构替换如下:

stringBuilder.Replace(" http://schemas.microsoft.com/ado/2008/09/mapping/cs ", " http://schemas.microsoft.com/ado/2009/11/mapping/cs "); stringBuilder.Replace(" http://schemas.microsoft.com/ado/2008/09/edm ", " http://schemas.microsoft.com/ado/2009/11/edm "); stringBuilder.Replace(" http://schemas.microsoft.com/ado/2008/10/edmx "," http://schemas.microsoft.com/ado/2009/11/edmx "); stringBuilder.Replace(“ http://schemas.microsoft.com/ado/2009/02/edm/ssdl ”,“ http://schemas.microsoft.com/ado/2009/11/edm/ssdl ”);

我仍然有以下错误:

警告 3 默认目标实体框架版本需要 edmx 架构版本 2.0.0.0 或更低版本。指定的架构是版本 3.0.0.0。为避免此警告,请明确指定目标实体框架版本。您可以通过使用带有 targetVersion 选项的 EdmGen.exe 命令行工具来执行此操作,或者在调用 GenerateCode 方法时包含 targetEntityFrameworkVersion 参数。

知道如何使用模板解决这个问题吗?

使用模板将 /targetversion:4.5 添加到 EdmGen 的等价物是什么?

4

1 回答 1

3

我找到了解决问题的方法...

以下链接中有一个领先的帮助:

http://blog.3d-logic.com/2012/05/28/entity-framework-code-first-and-pre-generated-views/

moozzyk 说:
2012 年 8 月 5 日晚上 11:51

我在使用 Visual Studio 2012 和 EF5 时确实看到了这一点。目前解决方法是编辑 >template。将第 70 行更改为: var errors = viewGenerator.GenerateViews(mappingItemCollection, writer).ToList(); to: var errors = viewGenerator.GenerateViews(mappingItemCollection, writer, > EntityFrameworkVersions.Version3 ).ToList(); 带来不便敬请谅解。

我不得不以类似的方式稍微修改我的代码,来自:

IList 错误 = viewGenerator.GenerateViews(mappingItems, writer);

至:

IList 错误 = viewGenerator.GenerateViews(mappingItems, writer, EntityFrameworkVersions.Version3 );

之后,没有任何警告或错误。

于 2013-07-16T10:49:43.410 回答