EF error CreateDatabase is not Supported by the provider
Hi
I am still in development and a programming newbie, someone recommended linqpad to help me learn about Lambda expressions and Linq, however I have set it up and my database tables are showing in the left hand panel, however when I run a query I get:
5DataException 4
An exception occurred while initializing the database. See the InnerException for details.
Message An exception occurred while initializing the database. See the InnerException for details.
Data IDictionary (0 items)
InnerException 6ProviderIncompatibleException 4
CreateDatabase is not supported by the provider.
Message CreateDatabase is not supported by the provider.
Data IDictionary (0 items)
InnerException null
TargetSite 6RuntimeMethodInfo 4
DbProviderServices.DbCreateDatabase (DbConnection connection, Int32? commandTimeout, StoreItemCollection storeItemCollection)
Name DbCreateDatabase
DeclaringType typeof (DbProviderServices)
ReflectedType typeof (DbProviderServices)
MemberType Method
MetadataToken 100667832
Module 6RuntimeModule 4
System.Data.Entity.dll
MDStreamVersion 131072
FullyQualifiedName C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Entity.dll
ModuleVersionId e38c3fba-4060-4078-a61d-82986bc6f760
MetadataToken 1
ScopeName System.Data.Entity.dll
Name System.Data.Entity.dll
Assembly 6RuntimeAssembly 4
System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
CodeBase file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.Entity/v4.0_4.0.0.0__b77a5c561934e089/System.Data.Entity.dll
FullName System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
EntryPoint null
Evidence 4Evidence 4
How do I solve this?
I am still in development and a programming newbie, someone recommended linqpad to help me learn about Lambda expressions and Linq, however I have set it up and my database tables are showing in the left hand panel, however when I run a query I get:
5DataException 4
An exception occurred while initializing the database. See the InnerException for details.
Message An exception occurred while initializing the database. See the InnerException for details.
Data IDictionary (0 items)
InnerException 6ProviderIncompatibleException 4
CreateDatabase is not supported by the provider.
Message CreateDatabase is not supported by the provider.
Data IDictionary (0 items)
InnerException null
TargetSite 6RuntimeMethodInfo 4
DbProviderServices.DbCreateDatabase (DbConnection connection, Int32? commandTimeout, StoreItemCollection storeItemCollection)
Name DbCreateDatabase
DeclaringType typeof (DbProviderServices)
ReflectedType typeof (DbProviderServices)
MemberType Method
MetadataToken 100667832
Module 6RuntimeModule 4
System.Data.Entity.dll
MDStreamVersion 131072
FullyQualifiedName C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Data.Entity\v4.0_4.0.0.0__b77a5c561934e089\System.Data.Entity.dll
ModuleVersionId e38c3fba-4060-4078-a61d-82986bc6f760
MetadataToken 1
ScopeName System.Data.Entity.dll
Name System.Data.Entity.dll
Assembly 6RuntimeAssembly 4
System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
CodeBase file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Data.Entity/v4.0_4.0.0.0__b77a5c561934e089/System.Data.Entity.dll
FullName System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
EntryPoint null
Evidence 4Evidence 4
How do I solve this?
Comments
partial class MyContext
{
partial void OnContextCreated()
{
if (!DatabaseExists()) CreateDatabase();
}
}
The fix couldn’t be easier: just override the three methods in the class LINQPadSqlOrCEProviderServices and delegate the calls to the wrapped object “_proxy”.
Hopefully it’s not too much troubles to fix and it would be much appreciated to get it fixed ASAP, since currently it’s really a showstopper in using this outstanding and really indispensable tool.
Oh by the way - just of curiosity - what is the reason of calling protected methods GetDbProviderManifest() and GetDbProviderManifestToken() of DbProviderServices directly via reflection and not just using their public “wrappers” GetProviderManifest() and GetProviderManifestToken() respectively?
www.linqpad.net/beta.aspx
Maybe I should think before I type. This might not be relevant when you're using a custom EF class library?
protected override void DbCreateDatabase(DbConnection connection, int? commandTimeout, StoreItemCollection storeItemCollection)
{
base.DbCreateDatabase(this.Unwrap(connection), commandTimeout, storeItemCollection);
}
which should actually call this._proxy.CreateDatabase() instead.
The rest of the DDL-methods do this right, only DbCreateDatabase does not. Because of that, a workaround is possible: manually create an empty database and use ExecuteStoreCommand(CreateDatabaseScript()) to populate its structure.