Home

EF error CreateDatabase is not Supported by the provider

edited June 2012
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?

Comments

  • edited June 2012
    I’m experiencing the same problem. It happens if the custom context class derived from System.Data.Objects.ObjectContext which LINQPad uses, makes use of any of the three methods DatabaseExists(),CreateDatabase() or CreateDatabaseScript(). It can be useful in some initialization scenarios, e.g.:

    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?
  • Thanks for reporting. This is now fixed in 4.42.5:
    www.linqpad.net/beta.aspx
  • It now works, thank you!
  • I'm still having this problem. I went to the beta section of the site and I only see version 4.42.06. Was the 4.42.5 a typo? Did you mean 4.42.05?
  • 4.42.5 == 4.42.05. Are you getting the identical error?
  • Sorry for being the n00b here, but how do you override the mentioned methods? Write a new class that inherits from LINQPadSql...? How do you get LINQPad to use your class?

    Maybe I should think before I type. This might not be relevant when you're using a custom EF class library?
  • This is broken for me on V4.43.06
  • FWIW, this is broken for me also with V4.43.06.
  • I can confirm this is a regression in V4.43.06. The reason is the following code in the LINQPadSqlOrCEProviderServices class:

    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.
  • This should now be fixed in the latest beta: www.linqpad.net/beta.aspx
Sign In or Register to comment.