0

EF Code First works on my localhost. However the problem occurs when I publish it to 1and1.com shared windows hosting. I can't connect via management studio so I guess the shared hosting doesn't support remote client connections. The Package Manager Console's Update Database can also not remote connect.

My config connectionstring is

<add name="DefaultConnection" connectionString="Data Source=dbXXXXXXXX.db.1and1.com;Initial Catalog=dbXXXXXXXX;User Id=username;Password=password;" providerName="System.Data.SqlClient" />

I copied my local sql from my package manager console to recreate the database through 1and1.com's web interface called myLittleAdmin.

I get the following error when I access the /Account/Register url

Migrations is enabled for context 'MyCustomDb' but the database does not exist or contains no mapped tables. Use Migrations to create the database and its tables, for example by running the 'Update-Database' command from the Package Manager Console.

I tried to disable migrations In my Global.asax I commented out the simplememebership provider Initialize

WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Users", "UserId", "UserName", autoCreateTables: true);

It did previously create the membership tables for me so it means the connection works

In my Db project in my solution where entity framework is installed I set automatic migrations as false

  public Configuration()
        {
            AutomaticMigrationsEnabled = false;
        }

I still get the same "Migrations is Enabled" error after publishing it via FTP. I just don't want to get an error. How do I get around this?

I could delete my Migration folder that contains Configuration.cs in it but then the seed method won't work.

greay
  • 1,725
  • 5
  • 18
  • 37
  • I ended up remving Migrations by removing the Migrations folder that contains the Configuration.cs file from my EF project. This is far from the ideal solution but I don't have much choice. – greay Oct 18 '13 at 23:40

1 Answers1

0

My advice is to execute a script EF has generated for you inside VS on production machine if it has SQL Server running

Antun Tun
  • 1,507
  • 5
  • 20
  • 38