MySql and Entity framework randomly gives Schema specified is not valid error

entity-frameworklinq-to-entitiesmysqlssdlvb.net

I'm using Entity Framework to access my MySQL database. The model was generated using EDMGEN2 and everything works great. I can do all my linq-to-entity query goodness…

…until an indeterminate amount of time passes and I get "The ProviderManifestToken '5' is different from '5.1' that was encountered earlier" error. Why is it encountering a '5' to begin with when I've only specified '5.1'?!!?

The only way to get the error to stop is to reupload to edmx file (which has not changed at all), overwriting the previous one. At that point the application will happily chug along serving data to users until BAM the error occurs maybe a few hours later, sometimes days later and I'll have to start chasing my tail again.

I've tried changing the ProviderManifestToken="5.1" to "MySQL", "6", "5" and the same situation will occur: works for a while then the error. As a bonus I only have this ONE edmx file in the vb.net webforms application so what is it getting confused by?

the first few lines of my edmx file looks like:

<edmx:Edmx Version="1.0" xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx">
<edmx:Runtime>
<edmx:StorageModels>
<Schema Namespace="v2Model.Store" Alias="Self" Provider="MySql.Data.MySqlClient" ProviderManifestToken="5.1" xmlns:store="http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator" xmlns="http://schemas.microsoft.com/ado/2006/04/edm/ssdl">
  <EntityContainer Name="v2ModelStoreContainer">.....

and my connection string in web.config looks like:

<add name="v2Entities" connectionString="metadata=res://*;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;database=v2;uid=username;pwd=password&quot;" providerName="System.Data.EntityClient" />

This has been going on for the last month now and I cannot figure out the source of the problem for the life of me! Any suggestions at all will be appreciated

Setup is as follows:

Windows Server 2003
MySQL v 5.1.38 (also tried on 5.1.36)
Connector/NET 6.1.1.0 (also tried on 6.0.4.0)

The error is as follows:

Schema specified is not valid. Errors:
MySql.Data.Entity.Properties.SchemaDefinition-5.1.ssdl(4,9) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '5' is different from '5.1' that was encountered earlier.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(4,9) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '5' is different from '5.1' that was encountered earlier.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(7,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'Schema' is already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(336,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Table' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(348,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.TableColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(374,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.View' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(386,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(412,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Function' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(437,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Procedure' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(447,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Parameter' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(471,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Constraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(483,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.CheckConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(491,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ConstraintColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(500,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ForeignKeyConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(509,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ForeignKey' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(520,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(535,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.TableTableConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(548,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ConstraintConstraintColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(561,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ConstraintForeignKey' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(574,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.FromForeignKeyColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(587,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ToForeignKeyColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(600,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.TableTableColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(613,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewViewColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(626,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.FunctionFunctionParameter' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(639,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ProcedureProcedureParameter' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(652,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewViewConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(665,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewConstraintConstraintColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(678,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewConstraintForeignKey' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(691,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.FromForeignKeyViewColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-5.0.ssdl(704,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ToForeignKeyViewColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(4,9) : error 0169: All SSDL artifacts must target the same provider. The ProviderManifestToken '5' is different from '5.1' that was encountered earlier.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(7,4) : error 0019: The EntityContainer name must be unique. An EntityContainer with the name 'Schema' is already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(391,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Table' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(403,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.TableColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(429,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.View' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(441,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(467,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Function' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(492,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Procedure' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(502,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Parameter' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(526,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.Constraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(538,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.CheckConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(546,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ConstraintColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(555,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ForeignKeyConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(564,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ForeignKey' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(575,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(590,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.TableTableConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(603,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ConstraintConstraintColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(616,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ConstraintForeignKey' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(629,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.FromForeignKeyColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(642,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ToForeignKeyColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(655,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.TableTableColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(668,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewViewColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(681,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.FunctionFunctionParameter' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(694,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ProcedureProcedureParameter' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(707,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewViewConstraint' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(720,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewConstraintConstraintColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(733,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ViewConstraintForeignKey' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(746,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.FromForeignKeyViewColumn' was already defined.

MySql.Data.Entity.Properties.SchemaDefinition-6.0.ssdl(759,4) : error 0019: Each type name in a schema must be unique. Type name 'MySqlClient.ToForeignKeyViewColumn' was already defined.|

Best Solution

I'm still not sure of the exact cause but the following seems to fix the random crashing:

Changing the

metadata=res://*;

To the actual namespace of the EDMX file seems to work:

metadata=res://MyApplication.Entities;

The problem fixing connection string looks like the following now:

<add name="v2Entities" connectionString="metadata=res://MyApplication.Entities;provider=MySql.Data.MySqlClient;provider connection string=&quot;server=localhost;database=v2;uid=username;pwd=password&quot;" providerName="System.Data.EntityClient"/>
Related Question