Quantcast
Channel: entityframework Issue Tracker Rss Feed
Viewing all 9566 articles
Browse latest View live

Edited Unassigned: Several Canonical functions are not handled in the SQL Server Compact provider [1961]

$
0
0

Compare
InitializeCanonicalFunctionHandlers() in src\EntityFramework.SqlServerCompact\SqlGen\SqlGenerator.cs
and
InitializeCanonicalFunctionHandlers() in src\EntityFramework.SqlServer\SqlGen\SqlFunctionCallHandler.cs

Many canonical functions are not handled at all, including Truncate, Abs, Contains, StartsWith, EndsWith, and many date/time functions

Also see the dicscussion here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/819bb6d2-88b5-4832-9ea0-e8975465848d/sql-server-compact-data-provider-for-ef-does-not-support-some-entity-sql-canonical-functions?forum=sqlce

Created Unassigned: SQL Server Compact data provider for EF does not support some Entity SQL canonical functions [1962]

$
0
0
This is a re-post of the Connect issue http://connect.microsoft.com/SQLServer/feedback/details/812735, as suggested by ErikEJ on the SQL Compact forum (http://social.msdn.microsoft.com/Forums/sqlserver/en-US/819bb6d2-88b5-4832-9ea0-e8975465848d).

Problem description:
System.Data.SqlServerCe.Entity (v. 4.0) doesn't support some Entity SQL canonical functions. The complete support for canonical functions is vital important for database-agnostic applications using Entity Framework.
For instance, there is no support for such essential string functions as Edm.Contains, Edm.Starts and Edm.EndsWith, which apparently can be translated to CHARINDEX or LIKE operators. In fact, the CLR method String.StartsWith() is supported by the provider at LINQ-to-Entity level and gets indeed translated to CHARINDEX. But with ESQL, it does not. At the same time, the opposite method String.EndsWith(), leads to a weird exception “The function 'Reverse' is not supported by SQL Server Compact”, when using LINQ-to-Entity.
Even worse is the fact, that the ESQL translator doesn’t report the unsupported functions and just put them in the resulting SQL “as is”. This means, a round-trip to the database engine is required to detect an invalid query.

Moreover, there should be a documented mapping between EDM canonical and SQL Server Compact functions, as it exists for SQL Client: http://msdn.microsoft.com/en-us/library/cc716715.aspx.

I'll provide a simple repro soon.

Commented Unassigned: SQL Server Compact data provider for EF does not support some Entity SQL canonical functions [1962]

$
0
0
This is a re-post of the Connect issue http://connect.microsoft.com/SQLServer/feedback/details/812735, as suggested by ErikEJ on the SQL Compact forum (http://social.msdn.microsoft.com/Forums/sqlserver/en-US/819bb6d2-88b5-4832-9ea0-e8975465848d).

Problem description:
System.Data.SqlServerCe.Entity (v. 4.0) doesn't support some Entity SQL canonical functions. The complete support for canonical functions is vital important for database-agnostic applications using Entity Framework.
For instance, there is no support for such essential string functions as Edm.Contains, Edm.Starts and Edm.EndsWith, which apparently can be translated to CHARINDEX or LIKE operators. In fact, the CLR method String.StartsWith() is supported by the provider at LINQ-to-Entity level and gets indeed translated to CHARINDEX. But with ESQL, it does not. At the same time, the opposite method String.EndsWith(), leads to a weird exception “The function 'Reverse' is not supported by SQL Server Compact”, when using LINQ-to-Entity.
Even worse is the fact, that the ESQL translator doesn’t report the unsupported functions and just put them in the resulting SQL “as is”. This means, a round-trip to the database engine is required to detect an invalid query.

Moreover, there should be a documented mapping between EDM canonical and SQL Server Compact functions, as it exists for SQL Client: http://msdn.microsoft.com/en-us/library/cc716715.aspx.

I'll provide a simple repro soon.
Comments: Please close as duplicate of http://entityframework.codeplex.com/workitem/1961

Commented Unassigned: SQL Server Compact data provider for EF does not support some Entity SQL canonical functions [1962]

$
0
0
This is a re-post of the Connect issue http://connect.microsoft.com/SQLServer/feedback/details/812735, as suggested by ErikEJ on the SQL Compact forum (http://social.msdn.microsoft.com/Forums/sqlserver/en-US/819bb6d2-88b5-4832-9ea0-e8975465848d).

Problem description:
System.Data.SqlServerCe.Entity (v. 4.0) doesn't support some Entity SQL canonical functions. The complete support for canonical functions is vital important for database-agnostic applications using Entity Framework.
For instance, there is no support for such essential string functions as Edm.Contains, Edm.Starts and Edm.EndsWith, which apparently can be translated to CHARINDEX or LIKE operators. In fact, the CLR method String.StartsWith() is supported by the provider at LINQ-to-Entity level and gets indeed translated to CHARINDEX. But with ESQL, it does not. At the same time, the opposite method String.EndsWith(), leads to a weird exception “The function 'Reverse' is not supported by SQL Server Compact”, when using LINQ-to-Entity.
Even worse is the fact, that the ESQL translator doesn’t report the unsupported functions and just put them in the resulting SQL “as is”. This means, a round-trip to the database engine is required to detect an invalid query.

Moreover, there should be a documented mapping between EDM canonical and SQL Server Compact functions, as it exists for SQL Client: http://msdn.microsoft.com/en-us/library/cc716715.aspx.

I'll provide a simple repro soon.
Comments: Compare InitializeCanonicalFunctionHandlers() in src\EntityFramework.SqlServerCompact\SqlGen\SqlGenerator.cs and InitializeCanonicalFunctionHandlers() in src\EntityFramework.SqlServer\SqlGen\SqlFunctionCallHandler.cs Some canonical functions are not handled, including Truncate, Contains, StartsWith, EndsWith, and many date/time functions

Commented Unassigned: Several Canonical functions are not handled in the SQL Server Compact provider [1961]

$
0
0

Compare
InitializeCanonicalFunctionHandlers() in src\EntityFramework.SqlServerCompact\SqlGen\SqlGenerator.cs
and
InitializeCanonicalFunctionHandlers() in src\EntityFramework.SqlServer\SqlGen\SqlFunctionCallHandler.cs

Many canonical functions are not handled at all, including Truncate, Abs, Contains, StartsWith, EndsWith, and many date/time functions

Also see the dicscussion here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/819bb6d2-88b5-4832-9ea0-e8975465848d/sql-server-compact-data-provider-for-ef-does-not-support-some-entity-sql-canonical-functions?forum=sqlce
Comments: Pls close this, dupe of https://entityframework.codeplex.com/workitem/1962

Edited Unassigned: Several Canonical functions are not handled in the SQL Server Compact provider [1961]

$
0
0

Compare
InitializeCanonicalFunctionHandlers() in src\EntityFramework.SqlServerCompact\SqlGen\SqlGenerator.cs
and
InitializeCanonicalFunctionHandlers() in src\EntityFramework.SqlServer\SqlGen\SqlFunctionCallHandler.cs

Some canonical functions are not handled, including Truncate, Contains, StartsWith, EndsWith, and many date/time functions

Also see the dicscussion here: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/819bb6d2-88b5-4832-9ea0-e8975465848d/sql-server-compact-data-provider-for-ef-does-not-support-some-entity-sql-canonical-functions?forum=sqlce

Edited Issue: Designer: DDL Generation Template for SQL CE should seperate each statemenet with GO [824]

$
0
0
Currently this is not the case for all statements, and it would be consistent and convenient if this was the case.

Commented Issue: Designer: DDL Generation Template for SQL CE should seperate each statemenet with GO [824]

$
0
0
Currently this is not the case for all statements, and it would be consistent and convenient if this was the case.
Comments: Fixed by ErikEJ in changeset #59e224d NoGONOMore Fix for issue https://entityframework.codeplex.com/workitem/824 (DDL Generation Template for SQL CE should seperate each statemenet with GO)

Commented Unassigned: EF 6.x DbContextGenerator failures: VS2013 referencing incorrect file locations [1960]

$
0
0

#### In Visual Studio 2013 every time/way of adding an EF 6.x DbContextGenerator to a project with or after adding a new Entity Data Model from an existing SQL Server database generates the following errors:

_Compiling transformation: Metadata file 'E:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\EntityFramework.dll' could not be found_

_Compiling transformation: Metadata file 'E:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\..\IDE\Microsoft.Data.Entity.Design.dll' could not be found_

This occurs with Visual Studio 2013 default non-customized installations (have tried Professional and Ultimate versions) on the system C: drive. I have verified that the files _do not_ exist in this incorrect location indicated in the error messages, and that the files _do_ exist in the correct/default location:

```
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\EntityFramework.dll
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\Microsoft.Data.Entity.Design.dll
```


I have tried the obvious complete Visual Studio 2013 uninstall/reinstall, same with Entity Framework, trying stock Entity Framework 6.x then each of the stable (and the latest pre-release versions), and this same behavior occurs. Visual Studio keeps looking for the above files in an incorrect location on a different drive from the installation, and the transforming templates fail to generate successfully. The output files simply contain the text "ErrorGeneratingOutput"

I can reproduce this behavior consistently using the simplest of projects, even simply following the steps in the basic EF tutorial at asp.net, [EF Database First with ASP.NET MVC: Creating the Web Application and Data Models ](http://www.asp.net/mvc/tutorials/mvc-5/database-first-development/creating-the-web-application)

Is there a way to repair or uninstall/re-install these EF Tools in Visual Studio 2013 (like VS 2012 where they are seperate download/install) or even manually update the incorrect file reference locations somewhere?
Comments: This seems like a duplicate of https://entityframework.codeplex.com/workitem/1782. Apparently where VS is first installed on one drive and then reinstalled to a different drive the VS120COMNTOOLS is not updated and still points to the old location. This environment variable is being used in the T4 template and since it is incorrect the template cannot find dependencies. The fix/workaround is to update the VS120COMNTOOLS to point to right location. Follow the steps from this [SO thread](http://stackoverflow.com/questions/19867641/entity-framework-in-visual-studio-2013-library-not-found/19912856#19912856) to test if setting the variable fixes the issue and if it does change it permanently in the settings.

Edited Issue: Incorrect migrations generated when unmapped base generic types change [FixedIn6.1.0-alpha1] [AffectedLastRTM] [1820]

$
0
0
Note: I am logging this bug on behalf of an internal partner team. I can provide detailed repro steps by email.

The basic scenario is:

1. A database is created on a model that uses unmapped generic base types
2. Migrations is enabled
3. The model is updated with some changes in the unmapped generic base types. The actual non-generic entity types mapped are generally kept the same with the exception of a few added properties
4. A new migration is created

__Expected outcome:__

A migration containing the property additions is scaffolded.

__Actual outcome:__

An incorrect (and big) migration is generated that contains multiple drops and create for the same tables and constraints.

The scaffolded code also shows duplicate FKs that seem to reflect that FKs detection conventions are not working correctly (but this could be a separate issue).

Closed Task: FxCop on the Tooling [1510]

$
0
0
We should enable FxCop on the tooling code base.
Comments: Verified that BuildEFTools fails if StyleCop rules are broken

Commented Task: API review for API surface changes in 6.1.0 [1926]

$
0
0
We should review all public surface changes in 6.1.0 using the API review tool.


Here are some API related comments from the commit failure workaround work:

1. The name TransactionHandler suggests that it can do more than it can actually do. Given that we have IDbTransactionInterceptor, do we need to have the general concept of a TransactionHandler or can we steer the design towards the more constrained idea of a CommitFailuresHandler. We can call the default one "DefaultCommitFailuresHandler" and the one that implements the workaround something else, e.g. "LoggingCommitFailuresHandler" or "CheckingCommitFailuresHandler" (or some better idea).

2. DbConfiguration.SetTransactionHandler that doesn't take a provider name: In other cases we have called this the "default", e.g. SetDefaultHistoryContext, SetDefaultSpatialServices. We should try to be consistent.

3. SetTransactionHandler overloads that take a provider name: in other cases we have made the provider name the first parameter.

4. SetTransactionContext: Does knowledge about the transaction context really need to leak outside the transaction handler? Could things still work and be reasonably extensible without it being a public type?

5. Consider renaming __Transactions table to __TransactionHistory (which looks nice alongside __MigrationsHistory :)) or __TransactionLog

6. Consider renaming PruneTransactionRows => PruneTransactionHistory[Async] or PruneTransactionLog[Async]

7. Provide a way to get the transaction handler from any context (even DbContext), e.g. a static CommitFailuresHandler.FromContext(db)

8. Provider a way to remove all rows in application start, e.g. CommitFailuresHandler.FromContext(db).TruncateTransaction[History|Log|[Async]

9. Merge ExecutionStrategyKey and StoreKey?

Comments: Should also update http://msdn.microsoft.com/en-us/data/jj680697 with the new services

Created Unassigned: EF 6.02 Automatic Migration fails [1963]

$
0
0

__Environment:__

Windows 7 SP1 Home Premium
Visual Studio 2013 Express
MVC 5 (project was created using VS2013 express)
EF 6.02
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.

Our project runs fine in MVC 5 with EF 6.02 and it access the SQL Server 2008 R2 without a problem.

But we are facing a major problem with Automatic Migrations. If we try to do "update-database -verbose -force" we receive consistently the same error, the command just sits there for almost 5 minutes and then it display the following exception.

_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._

If we try to do any single change, that following exception and behavior persists.

```
PM> update-database -verbose -force

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.
Applying automatic migration: 201401042347019_AutomaticMigration.

--- it sits here for almost 5 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

Edited Unassigned: EF 6.02 Automatic Migration fails [1963]

$
0
0

__Environment:__

Windows 7 SP1 Home Premium
Visual Studio 2013 Express
MVC 5 (project was created using VS2013 express)
EF 6.02
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 without a problem as long as the Models Match the database. The Start-up Time is about 60 seconds during troubleshooting, 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 error about 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 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._

If we try to do any single change, and use Auto Migration, the following exception and behavior persists.

```
PM> update-database -verbose -force

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.
Applying automatic migration: 201401042347019_AutomaticMigration.

--- it sits here for almost 5 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

Edited Unassigned: EF 6.02 Automatic Migration fails [1963]

$
0
0

__Environment:__

Windows 7 SP1 Home Premium
Visual Studio 2013 Express
MVC 5 (project was created using VS2013 express)
EF 6.02
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 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

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.
Applying automatic migration: 201401042347019_AutomaticMigration.

--- it sits here for almost 5 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

Edited Unassigned: EF 6.02 Automatic Migration fails [1963]

$
0
0

__Environment:__

Windows 7 SP1 Home Premium
Visual Studio 2013 Express
MVC 5 (project was created using VS2013 express)
EF 6.02
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 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

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 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

Edited Unassigned: EF 6.02 Automatic Migration fails [1963]

$
0
0

__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

Commented Unassigned: EF 6.02 Automatic Migration fails [1963]

$
0
0

__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

Created Unassigned: TPH foreign key mapping use same column [1964]

$
0
0
I am using the TPH inheritance mapping on an existing database. That database has a `Tags` table that looks like this:

Table: `Tags`
Column: `Id` (int)
Column: `ItemId` (int)
Column: `TagType` (string)

The `TagType` column is the discriminator column and contains either "usertag" or "movietag". Depending on the type of tag (user- or movietag), the `ItemId` column refers to either the Id of a record in the `Users` or `Movies` table. This results in the following data model, which I have added to a small console application to test it:

namespace ConsoleApplication14
{
using System.Data.Entity;

internal class Program
{
private static void Main()
{
using (var db = new Context())
{
db.Database.Delete();
db.Database.Initialize(false);
}
}
}

public class User
{
public int Id { get; set; }
}

public class Movie
{
public int Id { get; set; }
}

public abstract class Tag
{
public int Id { get; set; }
}

public class UserTag : Tag
{
public int UserId { get; set; }
public virtual User User { get; set; }
}

public class MovieTag : Tag
{
public int MovieId { get; set; }
public virtual Movie Movie { get; set; }
}

public class Context : DbContext
{
public Context()
{
Database.SetInitializer<Context>(null);
}

public DbSet<User> Users { get; set; }
public DbSet<Movie> Movies { get; set; }
public DbSet<UserTag> UserTags { get; set; }
public DbSet<MovieTag> MovieTags { get; set; }

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Tag>()
.Map<UserTag>(m => m.Requires("TagType").HasValue("usertag"))
.Map<MovieTag>(m => m.Requires("TagType").HasValue("movietag"));

modelBuilder.Entity<UserTag>().Property(m => m.UserId).HasColumnName("ItemId");
modelBuilder.Entity<UserTag>().HasRequired(m => m.User).WithMany().HasForeignKey(m => m.UserId);

modelBuilder.Entity<MovieTag>().Property(m => m.MovieId).HasColumnName("ItemId");
modelBuilder.Entity<MovieTag>().HasRequired(m => m.Movie).WithMany().HasForeignKey(m => m.MovieId);
}
}
}

Now when I run this application I get the following exception:

`ItemId: : There is no property with name 'ItemId' defined in the type referred to by Role 'Tag'.`

I don't know how I can prevent this error from happening. It seems to me that this is a situation that occurs more than once in real-life databases, so I hope that there is a way to map this or that this can be fixed.

Edited Unassigned: TPH foreign key mapping use same column [1964]

$
0
0
I am using the TPH inheritance mapping on an existing database. That database has a `Tags` table that looks like this:

Table: `Tags`
Column: `Id` (int)
Column: `ItemId` (int)
Column: `TagType` (string)

The `TagType` column is the discriminator column and contains either "usertag" or "movietag". Depending on the type of tag (user- or movietag), the `ItemId` column refers to either the Id of a record in the `Users` or `Movies` table. This results in the following data model, which I have added to a small console application to test it:

namespace ConsoleApplication14
{
using System.Data.Entity;

internal class Program
{
private static void Main()
{
using (var db = new Context())
{
db.Database.Delete();
db.Database.Initialize(false);
}
}
}

public class User
{
public int Id { get; set; }
}

public class Movie
{
public int Id { get; set; }
}

public abstract class Tag
{
public int Id { get; set; }
}

public class UserTag : Tag
{
public int UserId { get; set; }
public virtual User User { get; set; }
}

public class MovieTag : Tag
{
public int MovieId { get; set; }
public virtual Movie Movie { get; set; }
}

public class Context : DbContext
{
public Context()
{
Database.SetInitializer<Context>(null);
}

public DbSet<User> Users { get; set; }
public DbSet<Movie> Movies { get; set; }
public DbSet<UserTag> UserTags { get; set; }
public DbSet<MovieTag> MovieTags { get; set; }

protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
modelBuilder.Entity<Tag>()
.Map<UserTag>(m => m.Requires("TagType").HasValue("usertag"))
.Map<MovieTag>(m => m.Requires("TagType").HasValue("movietag"));

modelBuilder.Entity<UserTag>().Property(m => m.UserId).HasColumnName("ItemId");
modelBuilder.Entity<UserTag>().HasRequired(m => m.User).WithMany().HasForeignKey(m => m.UserId);

modelBuilder.Entity<MovieTag>().Property(m => m.MovieId).HasColumnName("ItemId");
modelBuilder.Entity<MovieTag>().HasRequired(m => m.Movie).WithMany().HasForeignKey(m => m.MovieId);
}
}
}

Now when I run this application I get the following exception:

`ItemId: : There is no property with name 'ItemId' defined in the type referred to by Role 'Tag'.`

I don't know how I can prevent this error from happening. It seems to me that this is a situation that occurs more than once in real-life databases, so I hope that there is a way to map this or that this can be fixed.

My application is using Entity Framework 6.0.2.
Viewing all 9566 articles
Browse latest View live