2013-07-15 31 views
3

我已經預先生成的觀點:升級EF:默認目標實體框架版本需要遵循<strong>模板下一環節的</strong>在EDMX架構版本2或更低

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

我需要改善對實體框架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 ");

我仍然有以下錯誤:

Warning 3 The default target Entity Framework version requires the edmx schema version 2.0.0.0 or lower. The specified schema is version 3.0.0.0. To avoid this warning specify the target Entity Framework version explicitly. You can do this by using the EdmGen.exe command-line tool with the targetVersion option, or by including the targetEntityFrameworkVersion parameter when calling the GenerateCode method.

任何想法如何解決這個問題使用模板

使用模板添加/targetversion:4.5到EdmGen 的等效物是什麼?

回答

3

我找到了解決我的問題......

有下面的鏈接領先的幫助:

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

moozzyk says:
August 5, 2012 at 11:51 pm

I did see this when using Visual Studio 2012 and EF5. For now the workaround is to edit the >template. Change the line 70 from: var errors = viewGenerator.GenerateViews(mappingItemCollection, writer).ToList(); to: var errors = viewGenerator.GenerateViews(mappingItemCollection, writer, >EntityFrameworkVersions.Version3).ToList(); Sorry for the inconvenience.

我不得不slighlty修改我的代碼相似的來自:

IList errors = viewGenerator.GenerateViews(mappingItems, writer);

收件人:

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

之後,沒有任何警告或錯誤。