__Environment:__
Windows 7 SP1 Home Premium
Visual Studio 2013 Express
MVC 5 (project was created using VS2013 express)
EF 6.02
.Net 4.5 framework
AspNet.Providers.Core 2.0.0
AspNet.Providers 2.0.0
SQL Server 2008 R2
Code-First Models (220 models)
__Web.Config__
```
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework">
<parameters>
<parameter value="v11.0" />
</parameters>
</defaultConnectionFactory>
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
```
```
<connectionStrings>
<add name="ApplicationServices" connectionString="Data Source=localhost; Initial Catalog=aspnetdb; Integrated Security=True;" providerName="System.Data.SqlClient" />
<add name="I2CDB" connectionString="Data Source=localhost; Initial Catalog=I2CDBA; Integrated Security=True;" providerName="System.Data.SqlClient" />
<remove name="LocalSqlServer" />
<add name="LocalSqlServer" connectionString="Data Source=localhost; Initial Catalog=I2CDB; Integrated Security=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
```
We have created a fresh new MVC 5 project with EF 6.02 and imported all the Models from our previous MVC4 project (was created using VS 2010 SP1) by doing "Add Existing". I have a large ERP system with 220 entity models. We are using Code-First models.
__Problem__
Our project runs fine in MVC 5 with EF 6.02 and it access the SQL Server 2008 R2 (as well as SQL Server 2012) without a problem as long as the Models Match the database. The Start-up Time is about 60 seconds during a Debugging session, which is reasonable compared with more than 8 minutes with VS 2010 SP1.
However, in case there is a mismatch, then we have a major problem. The start-up time would go up to more than 10 minutes and then an error showing Database not matching the models.
The second major problem, is that we have to use Automatic Migration to update the database, and this when the entire thing fails. If we try to do "update-database -verbose -force" we receive consistently the same exception error shown below, the command just sits there for almost 5 minutes and then it display the following exception.
We tried to use "-script" option but it fails with the same exception. This renders Code-First totally unusable and therefore we can not migrate to the latest VS2013/.Net 4.5 framework/MVC5/EF6
_We have tried to redirect the Connection String to a fresh new database name, and it works fine. So "update-database -verbose -force" will create successfully the complete database. One we try to do any single change, and use Auto Migration, the following exception and behavior persists. We have tried with both SQL Server 2008 R2 and SQL Server 2012_
```
PM> update-database -verbose -force
--- or ---
PM> update-database -verbose -force -script
Using StartUp project 'inv2cash'.
Using NuGet project 'inv2cash'.
Specify the '-Verbose' flag to view the SQL statements being applied to the target database.
Target database is: 'I2CDB' (DataSource: localhost, Provider: System.Data.SqlClient, Origin: Configuration).
No pending explicit migrations.
--- it sits here for almost 5 minutes -----
Applying automatic migration: 201401042347019_AutomaticMigration.
--- it sits here for almost another 5 - 7 minutes and then .. boom :-----
System.Runtime.Remoting.RemotingException: Object '/c106cae8_4da0_4b6c_8882_bec38b8d1607/s6aojvpx65n33sjyi_9xvwqb_1369.rem' has been disconnected or does not exist at the server.
at System.Data.Entity.Migrations.Design.ToolingFacade.ToolLogger.Verbose(String sql)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.ExecuteSql(DbTransaction transaction, MigrationStatement migrationStatement)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatementsInternal(IEnumerable1 migrationStatements, DbConnection connection)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClass32.<ExecuteStatements>b__2e()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func1 operation)
at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)
at System.Data.Entity.Migrations.DbMigrator.ExecuteStatements(IEnumerable1 migrationStatements)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.ExecuteStatements(IEnumerable1 migrationStatements)
at System.Data.Entity.Migrations.DbMigrator.ExecuteOperations(String migrationId, XDocument targetModel, IEnumerable1 operations, IEnumerable1 systemOperations, Boolean downgrading, Boolean auto)
at System.Data.Entity.Migrations.DbMigrator.AutoMigrate(String migrationId, XDocument sourceModel, XDocument targetModel, Boolean downgrading)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.AutoMigrate(String migrationId, XDocument sourceModel, XDocument targetModel, Boolean downgrading)
at System.Data.Entity.Migrations.DbMigrator.Upgrade(IEnumerable1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.Infrastructure.MigratorLoggingDecorator.Upgrade(IEnumerable1 pendingMigrations, String targetMigrationId, String lastMigrationId)
at System.Data.Entity.Migrations.DbMigrator.UpdateInternal(String targetMigration)
at System.Data.Entity.Migrations.DbMigrator.<>c__DisplayClassc.<Update>b__b()
at System.Data.Entity.Migrations.DbMigrator.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.EnsureDatabaseExists(Action mustSucceedToKeepDatabase)
at System.Data.Entity.Migrations.DbMigrator.Update(String targetMigration)
at System.Data.Entity.Migrations.Infrastructure.MigratorBase.Update(String targetMigration)
at System.Data.Entity.Migrations.Design.ToolingFacade.UpdateRunner.Run()
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.AppDomain.DoCallBack(CrossAppDomainDelegate callBackDelegate)
at System.Data.Entity.Migrations.Design.ToolingFacade.Run(BaseRunner runner)
at System.Data.Entity.Migrations.Design.ToolingFacade.Update(String targetMigration, Boolean force)
at System.Data.Entity.Migrations.UpdateDatabaseCommand.<>c__DisplayClass2.<.ctor>b__0()
at System.Data.Entity.Migrations.MigrationsDomainCommand.Execute(Action command)
Object '/c106cae8_4da0_4b6c_8882_bec38b8d1607/s6aojvpx65n33sjyi_9xvwqb_1369.rem' has been disconnected or does not exist at the server.
```
This is very disturbing and stopping our migration to VS 2013 and to MVC 5.
Hope it will find some listening ears.
BR
Adel Mansour
Comments:
I have downloaded today the Nightly Build of EF 6.1.0 Alpha and this problem is not there in 6.1.0 Alpha !!
Somehow good news for us, but do we know what was the problem that was resolved in 6.1.0 that made this disappear !?
BR
Adel