Description:
The GetDbProviderManifestToken method of the MySqlProviderServices attempts to open a connection to the database in order to return the MySql version number.
If the database doesn't exist yet - for example, when using the code-first "context.Database.Exists()" method - this results in a ProviderIncompatibleException being thrown.
This also means that it's not possible to generate a script to create the database using EF4 unless the database already exists.
How to repeat:
Create an entity data model for a new database which doesn't exist yet.
Attempt to generate the script to create the database.
Result:
-------
System.Data.ProviderIncompatibleException
The provider did not return a ProviderManifestToken string.
StackTrace:
Server stack trace:
at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel()
at System.Lazy`1.CreateValue()
Exception rethrown at [0]:
at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest)
at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at System.Lazy`1.get_Value()
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.LazyInternalContext.GetObjectContextWithoutDatabaseInitialization()
at System.Data.Entity.Database.DbDatabase.Exists()
at App.VerifyDatabase()
InnerException: MySql.Data.MySqlClient.MySqlException
Access denied for user 'myuser'@'%' to database 'mydatabase'
ErrorCode=-2147467259
Number=1044
StackTrace:
at MySql.Data.MySqlClient.MySqlStream.ReadPacket()
at MySql.Data.MySqlClient.NativeDriver.AuthenticateNew()
at MySql.Data.MySqlClient.NativeDriver.Authenticate()
at MySql.Data.MySqlClient.NativeDriver.Open()
at MySql.Data.MySqlClient.Driver.Open()
at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings)
at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection()
at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver()
at MySql.Data.MySqlClient.MySqlPool.GetConnection()
at MySql.Data.MySqlClient.MySqlConnection.Open()
at MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection connection)
at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
Suggested fix:
If the database doesn't exist, fall back to a different database.
(For example, the MS-SQL provider falls back to the "master" database.)
If the connection still fails, fall back to a reasonable default.
(The MS-SQL provider doesn't currently do this, but it would probably be a good idea.)
Description: The GetDbProviderManifestToken method of the MySqlProviderServices attempts to open a connection to the database in order to return the MySql version number. If the database doesn't exist yet - for example, when using the code-first "context.Database.Exists()" method - this results in a ProviderIncompatibleException being thrown. This also means that it's not possible to generate a script to create the database using EF4 unless the database already exists. How to repeat: Create an entity data model for a new database which doesn't exist yet. Attempt to generate the script to create the database. Result: ------- System.Data.ProviderIncompatibleException The provider did not return a ProviderManifestToken string. StackTrace: Server stack trace: at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel() at System.Lazy`1.CreateValue() Exception rethrown at [0]: at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) at System.Data.Entity.ModelConfiguration.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) at System.Data.Entity.ModelConfiguration.ModelBuilder.Build(DbConnection providerConnection) at System.Data.Entity.Internal.LazyInternalContext.CreateModel() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at System.Lazy`1.get_Value() at System.Data.Entity.Internal.LazyInternalContext.InitializeContext() at System.Data.Entity.Internal.LazyInternalContext.GetObjectContextWithoutDatabaseInitialization() at System.Data.Entity.Database.DbDatabase.Exists() at App.VerifyDatabase() InnerException: MySql.Data.MySqlClient.MySqlException Access denied for user 'myuser'@'%' to database 'mydatabase' ErrorCode=-2147467259 Number=1044 StackTrace: at MySql.Data.MySqlClient.MySqlStream.ReadPacket() at MySql.Data.MySqlClient.NativeDriver.AuthenticateNew() at MySql.Data.MySqlClient.NativeDriver.Authenticate() at MySql.Data.MySqlClient.NativeDriver.Open() at MySql.Data.MySqlClient.Driver.Open() at MySql.Data.MySqlClient.Driver.Create(MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.MySqlPool.CreateNewPooledConnection() at MySql.Data.MySqlClient.MySqlPool.GetPooledConnection() at MySql.Data.MySqlClient.MySqlPool.TryToGetDriver() at MySql.Data.MySqlClient.MySqlPool.GetConnection() at MySql.Data.MySqlClient.MySqlConnection.Open() at MySql.Data.MySqlClient.MySqlProviderServices.GetDbProviderManifestToken(DbConnection connection) at System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) Suggested fix: If the database doesn't exist, fall back to a different database. (For example, the MS-SQL provider falls back to the "master" database.) If the connection still fails, fall back to a reasonable default. (The MS-SQL provider doesn't currently do this, but it would probably be a good idea.)