Upgrading EF in pregenerated views: The default target Entity Framework version requires the edmx schema version 2 or lower

StackOverflow https://stackoverflow.com/questions/17654484

Domanda

I have pre-generated views following the templates of the next link:

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

I need to improve to Entity Framework 5.0 but if I replace the schemas as following:

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");

I still having the following error:

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.

Any idea of how to solve this issue using templates?

What is the equivalent of adding /targetversion:4.5 to EdmGen using templates?

È stato utile?

Soluzione

I found the solution to my problem...

There was a leading help in the following link:

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.

I had to slighlty modify my code in a similar way, from:

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

To:

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

After that, no warning nor error whatsoever.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top