0

Is it possible that the connection string is redirected to a method (instead using App.config)?

(App.config is not an option because the location for a sdf can be changed)

My connection string (sdf) can change via an OpenFileDialog for instance.

The hint concerning SQLExpress was seen.

When debugging, the migration goes towards the IMigrationMetadata.Id.

Then, DataException - An exception occurred while initializing the database. at

System.Data.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
    ProviderIncompatibleException - The provider did not return a ProviderManifestToken string.
    {"An error occurred while getting provider information from the database. This can be caused by Entity Framework using an incorrect connection string. "}

at System.Data.Entity.ModelConfiguration.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)

The default ctor applies a connection string that cannot be used:

Data Source=.\SQLEXPRESS;Initial Catalog=Namespace.AbacusContext;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFrameworkMUE

But when invoking

this.Database.Initialize( false ); //good connStr applied

within a ctor (incl. arguments), then the default ctor is automatically invoked (but not by me) and that uses an impaired connection string. See overview:

 public AbacusContext( DbConnection connection, bool contextOwnsConnection ) :
            base( connection, contextOwnsConnection )
        {
            Database.SetInitializer( new MigrateDatabaseToLatestVersion<AbacusContext, Configuration>() );
            string goodConnStr = this.Database.Connection.ConnectionString;//was used for a breakpoint
            this.Database.Initialize( false );
        }

        public AbacusContext() 
        {
           string badConnStr = this.Database.Connection.ConnectionString;
            //SQLExpress and some other stuff can be seen now
        }
mnemonic
  • 1,605
  • 2
  • 17
  • 26
  • So you are trying to change your connection string at runtime? http://stackoverflow.com/questions/20216147/entity-framework-change-connection-at-runtime – Steve Greene Jul 21 '15 at 18:28
  • have read the content. it does not fit for me. still the same issue. – mnemonic Jul 22 '15 at 09:27

0 Answers0