My pre-generated views for EF4 Code First using this T4 template does not work in the build server. I am not re-generating the view in the build server, just compile and run the MSTest. Error is thrown when the tests are ran:
System.Data.MappingException: The mapping and metadata information for EntityContainer 'DB' no longer matches the information used to create the pre-generated views
I ran the same template in another machine and the hash values are different. I guess this is the reason why its it does not work in the build server. The hash values are different at runtime in other machines, hence the verification fails and throws the exception.
Im using:
- VS 2010 Pro
- .Net Framework v4.0.30319
- Entity Framework v4.2 (Code First)
- EF CodeFirst View Generation T4 Template for C# (v1.0.1) - slightly modified GetEdmxSchemaVersion to return the correct EntityFrameworkVersions version for my setup.
- using Class Library project template
The tests that I am running connects to a SQL DB file that is checked in with the code.
I have checked the build server and its using the same EF dll version and .Net Framework version.
Any idea why the hash values are different?
UPDATE: I've generated and compared two XML file from two dev machines using EdmxWriter.WriteEdmx().
Here is schema version (the same in both machine):
<?xml version="1.0" encoding="utf-8"?>
<Edmx Version="2.0" xmlns="http://schemas.microsoft.com/ado/2008/10/edmx">
The obvious difference are the order some nodes in the XML files. Here is an example:
Machine 1:
<EntityType Name="PersonEntity" BaseType="Self.Entity" />
<EntityType Name="CompanyEntity" BaseType="Self.Entity" />
Machine 2:
<EntityType Name="CompanyEntity" BaseType="Self.Entity" />
<EntityType Name="PersonEntity" BaseType="Self.Entity" />
Any idea why they are in different order?
UPDATE 2: The Edmx (xml) from the build server is also different for the other 2 dev machines. Again, the order of some nodes are different.
Machine 1 and build server both have System.Data.Entity.dll (same File and Product version -- v4.0.30319.1) in %windir%\Microsoft.NET\assembly\GAC_MSIL\System.Data.Entity\v4.0_4.0.0.0__b77a5c561934e089.
UPDATE 3: I also looked at the version of System.Data.Entity.Design.dll. The T4 template references this assembly. Machine 1 has two copies of this dll ... in GAC (v4.0.30319.233) and in C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.0 (v4.0.30319.1). This is also true in the build server and Machine 2. I wonder if hash validation function during runtime is using this dll as its not referenced in my project. If it does, which version is used. But then again, the hash validation is successful in Machine 1.