Quantcast
Channel: Entity Framework
Viewing all 10318 articles
Browse latest View live

Created Unassigned: "Duplicate type name within an assembly" [2228]

0
0
Web Site project works ok with the DbContext. And I created windows forms application with the DbContext. It’s works ok too.
I think there is a problem with Windows Azure Emulator. Can anybody give me some help?

Windows 8.1 x64
Target Framework: .NET Framework 4.5.1

Content of «packages.config» file of «ProgressCalc» project:
---
<!--
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net451" />
<package id="System.Spatial" version="5.6.0" targetFramework="net451" />
<package id="WindowsAzure.Storage" version="3.1.0.1" targetFramework="net451" />
</packages>
-->

---
![Image](http://6.firepic.org/6/images/2014-04/18/2c3e8ouhonlj.png)

Commented Unassigned: "Duplicate type name within an assembly" [2228]

0
0
Web Site project works ok with the DbContext. And I created windows forms application with the DbContext. It’s works ok too.
I think there is a problem with Windows Azure Emulator. Can anybody give me some help?

Windows 8.1 x64
Target Framework: .NET Framework 4.5.1

Content of «packages.config» file of «ProgressCalc» project:
---
<!--
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net451" />
<package id="System.Spatial" version="5.6.0" targetFramework="net451" />
<package id="WindowsAzure.Storage" version="3.1.0.1" targetFramework="net451" />
</packages>
-->

---
![Image](http://6.firepic.org/6/images/2014-04/18/2c3e8ouhonlj.png)
Comments: Windows Azure Compute Emulator has version number 2.3.0.0 Windows Azure Storage Emulator has version number 3.0.0.0

Edited Unassigned: "Duplicate type name within an assembly" [2228]

0
0
Web Site project works ok with the DbContext. And I created windows forms application with the DbContext. It’s works ok too.
I think there is a problem with Windows Azure Emulator. Can anybody give me some help?

Windows 8.1 x64
Target Framework: .NET Framework 4.5.1
Windows Azure Compute Emulator has version number 2.3.0.0
Windows Azure Storage Emulator has version number 3.0.0.0

Content of «packages.config» file of «ProgressCalc» project:
---
<!--
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net451" />
<package id="System.Spatial" version="5.6.0" targetFramework="net451" />
<package id="WindowsAzure.Storage" version="3.1.0.1" targetFramework="net451" />
</packages>
-->

---
![Image](http://6.firepic.org/6/images/2014-04/18/2c3e8ouhonlj.png)

New Post: Exception: Duplicate type name within an assembly

0
0
Web Site project works ok with the DbContext. And I created windows forms application with the DbContext. It’s works ok too.
I think there is a problem with Windows Azure Emulator. Can anybody give me some help?

Windows 8.1 x64
Target Framework: .NET Framework 4.5.1
Windows Azure Compute Emulator has version number 2.3.0.0
Windows Azure Storage Emulator has version number 3.0.0.0

Content of «packages.config» file of «ProgressCalc» project:

<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.1.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.Core" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.0.0" targetFramework="net451" />
<package id="Microsoft.Data.Edm" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.Data.OData" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.Data.Services.Client" version="5.6.0" targetFramework="net451" />
<package id="Microsoft.WindowsAzure.ConfigurationManager" version="2.0.3" targetFramework="net451" />
<package id="Newtonsoft.Json" version="6.0.2" targetFramework="net451" />
<package id="System.Spatial" version="5.6.0" targetFramework="net451" />
<package id="WindowsAzure.Storage" version="3.1.0.1" targetFramework="net451" />

</packages>

Image

New Post: EF 6.1 Migrations with multiple dbcontexts with class models inheriting from common abstract class

0
0
It looks like the answer is to remove the content base class from the plugin content model.
public partial class NewsModel : DbContext
    {
        public NewsModel()
            : base( "name=NewsModel" )
        {
        }
        
        public NewsModel( String connectionString )
            : base( connectionString )
        {
        }

        public virtual DbSet<ContentBase> ContentBaseSet { get; set; }
        public virtual DbSet<Tag> Tags { get; set; }

        public virtual DbSet<NewsItem> News { get; set; }
        public virtual DbSet<NewsFeed> NewsFeeds { get; set; }

        protected override void OnModelCreating( DbModelBuilder modelBuilder )
        {
        }
    }
Then, within OnModelCreating() somehow use the modelBuilder to map to the contentBase table ( I need to keep using TPT inheritance for existing production databases ).

Thanks in advance for any help.

Commented Unassigned: SqlFunctions broken? [1774]

0
0
Hi.

I am trying to run this simple query:
```
var result = (from x in context.TestTable
where SqlFunctions.StringConvert(x.Id) == "1"
select x).ToList();
```

But I am receiving this error message:
Exception:Thrown: "The specified method 'System.String StringConvert(System.Nullable`1[System.Decimal])' on the type 'System.Data.Entity.SqlServer.SqlFunctions' cannot be translated into a LINQ to Entities store expression." (System.NotSupportedException)

Could it be that my provider needs to fix things or is this related to EF6 core features?
The namespace (System.Data.Entity.SqlServer.SqlFunctions) leads me to the believe that those functions only work for SqlServer, and when I want to use a different database I have to use their "SqlFunctions" or?

using EF6 with firebird database.
Comments: @shiloh69, instead of StringConvert, you can just call .ToString(), it works in EF6.

Edited Feature: UpForGrabs: The cast to value type 'XY' failed because the materialized value is null. [2227]

0
0
Could the
```
System.Data.Entity.Core.Common.Internal.Materialization.Shaper.ErrorHandlingValueReader`1.GetValue(DbDataReader reader, Int32 ordinal)
```
pretty please include the column ordinal in the exception? This way it's sometimes quite hard to guess which of those twenty selected columns is null unexpectedly. The name of the column would be even better, though that'd require catching the exception somewhere in System.Data.Entity.Core.Common.Internal.Materialization.Coordinator`1.ReadNextElement() or some place like that and throwing a new one with additional data.

Thanks!

Edited Feature: 6.1 Reverse Engineer Code First doesn't create mapping files [2220]

0
0
When reverse engineering to Code First, EF Power Tools used to create 'mapping' files (EntityTypeConfiguration<T>). 6.1 reverse engineer tooling does not. Creating these files is half the point of the tool. Please upgrade the tool generate mapping files by default, as the previous releases did. Thanks!

Closed Unassigned: Index-attribute clustered to override default clustered keys [2212]

0
0
Let's create an object:
```
public class Entity {
[Key]
public int EntityID { get; set; }
public string EntityName { get; set; }
}
```

EF will create the following table:
```
CREATE TABLE [dbo].[Entities](
[EntityID] [int] IDENTITY(1,1) NOT NULL,
[EntityName] [nvarchar](max) NULL,
CONSTRAINT [PK_dbo.leerjaren] PRIMARY KEY CLUSTERED
(
[leerjaarID] ASC
)
```

We just migrated to EF6.1, so let's add an index on the EntityName property, and let's make it clustered because we want it for performance:

```
public class Entity {
[Key]
public int EntityID { get; set; }
[Index(IsClustered = true)]
public string EntityName { get; set; }
}
```

And then... problem. The database complains it gets a second Clustered Index, which is not possible.
As far as I know it is not possible to create non-clustered Primary Keys in Code First, so maybe add something that a new Clustered Index overrides the existing if it is a primary key?
Comments: Resolving this as a duplicate of #2163 which is more general and has more votes although I think the proposed solution here sounds good.

Commented Unassigned: Index-attribute clustered to override default clustered keys [2212]

0
0
Let's create an object:
```
public class Entity {
[Key]
public int EntityID { get; set; }
public string EntityName { get; set; }
}
```

EF will create the following table:
```
CREATE TABLE [dbo].[Entities](
[EntityID] [int] IDENTITY(1,1) NOT NULL,
[EntityName] [nvarchar](max) NULL,
CONSTRAINT [PK_dbo.leerjaren] PRIMARY KEY CLUSTERED
(
[leerjaarID] ASC
)
```

We just migrated to EF6.1, so let's add an index on the EntityName property, and let's make it clustered because we want it for performance:

```
public class Entity {
[Key]
public int EntityID { get; set; }
[Index(IsClustered = true)]
public string EntityName { get; set; }
}
```

And then... problem. The database complains it gets a second Clustered Index, which is not possible.
As far as I know it is not possible to create non-clustered Primary Keys in Code First, so maybe add something that a new Clustered Index overrides the existing if it is a primary key?
Comments: Proper link to #2163.

Commented Unassigned: Index-attribute clustered to override default clustered keys [2212]

0
0
Let's create an object:
```
public class Entity {
[Key]
public int EntityID { get; set; }
public string EntityName { get; set; }
}
```

EF will create the following table:
```
CREATE TABLE [dbo].[Entities](
[EntityID] [int] IDENTITY(1,1) NOT NULL,
[EntityName] [nvarchar](max) NULL,
CONSTRAINT [PK_dbo.leerjaren] PRIMARY KEY CLUSTERED
(
[leerjaarID] ASC
)
```

We just migrated to EF6.1, so let's add an index on the EntityName property, and let's make it clustered because we want it for performance:

```
public class Entity {
[Key]
public int EntityID { get; set; }
[Index(IsClustered = true)]
public string EntityName { get; set; }
}
```

And then... problem. The database complains it gets a second Clustered Index, which is not possible.
As far as I know it is not possible to create non-clustered Primary Keys in Code First, so maybe add something that a new Clustered Index overrides the existing if it is a primary key?
Comments: Proper link to [#2163](https://entityframework.codeplex.com/workitem/2163).

Commented Unassigned: Index-attribute clustered to override default clustered keys [2212]

0
0
Let's create an object:
```
public class Entity {
[Key]
public int EntityID { get; set; }
public string EntityName { get; set; }
}
```

EF will create the following table:
```
CREATE TABLE [dbo].[Entities](
[EntityID] [int] IDENTITY(1,1) NOT NULL,
[EntityName] [nvarchar](max) NULL,
CONSTRAINT [PK_dbo.leerjaren] PRIMARY KEY CLUSTERED
(
[leerjaarID] ASC
)
```

We just migrated to EF6.1, so let's add an index on the EntityName property, and let's make it clustered because we want it for performance:

```
public class Entity {
[Key]
public int EntityID { get; set; }
[Index(IsClustered = true)]
public string EntityName { get; set; }
}
```

And then... problem. The database complains it gets a second Clustered Index, which is not possible.
As far as I know it is not possible to create non-clustered Primary Keys in Code First, so maybe add something that a new Clustered Index overrides the existing if it is a primary key?
Comments: Link to [#2163](https://entityframework.codeplex.com/workitem/2163).

Created Unassigned: This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original database connection has been opened and credentials have been removed from the connection string. [2229]

0
0
He are getting an error with no sense from EF. After we restart the IIS Application pool, we stoped getting the error which is the worst case scenario we can face.

Here is the error message:

```
Message : An error occurred while starting a transaction on the provider connection. See the inner exception for details.
Source : EntityFramework
Stack Trace : at System.Data.Entity.Core.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel)
at System.Data.Entity.Core.EntityClient.EntityConnection.BeginTransaction()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at FooBar.&lt;UpdateAccessInformation&gt;d__f.MoveNext() in c:\Users\FooBar\Dropbox\Foo\Foo\Foo\FooBar.cs:line 128
---- Inner Exception ----
Message : An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.
Source : EntityFramework
Stack Trace : at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes()
at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()
at System.Data.Entity.Infrastructure.CommitFailureHandler.BeganTransaction(DbConnection connection, BeginTransactionInterceptionContext interceptionContext)
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.BeginTransaction(DbConnection connection, BeginTransactionInterceptionContext interceptionContext)
at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel)
---- Inner Exception ----
Message : The provider did not return a ProviderManifestToken string.
Source : EntityFramework
Stack Trace : at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
---- Inner Exception ----
Message : This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original database connection has been opened and credentials have been removed from the connection string. Supply an unopened connection.
Source : EntityFramework.SqlServer
Stack Trace : at System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act)
at System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection)
at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
---- Inner Exception ----
Message : Login failed for user 'MY_USER_NAME'.
Source : .Net SqlClient Data Provider
Data : Key : HelpLink.ProdName Value : Microsoft SQL Server
Data : Key : HelpLink.EvtSrc Value : MSSQLServer
Data : Key : HelpLink.EvtID Value : 18456
Data : Key : HelpLink.BaseHelpUrl Value : http://go.microsoft.com/fwlink
Data : Key : HelpLink.LinkId Value : 20476
Stack Trace : at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean&amp; dataReady)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal&amp; connection)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
at System.Data.Entity.Infrastructure.DbExecutionStrategy.&lt;&gt;c__DisplayClass1.&lt;Execute&gt;b__0()
at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act)
at System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act)
---- End of Exception Details ----
```

What would be causing this.

Thanks!

Edited Unassigned: This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original database connection has been opened and credentials have been removed from the connection string. [2229]

0
0
We are getting an error with no sense from EF. After we restart the IIS Application pool, we stoped getting the error which is the worst case scenario we can face.

Here is the error message:

```
Message : An error occurred while starting a transaction on the provider connection. See the inner exception for details.
Source : EntityFramework
Stack Trace : at System.Data.Entity.Core.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel)
at System.Data.Entity.Core.EntityClient.EntityConnection.BeginTransaction()
at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesToStore(SaveOptions options, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction)
at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.Objects.ObjectContext.SaveChangesInternal(SaveOptions options, Boolean executeInExistingTransaction)
at System.Data.Entity.Internal.InternalContext.SaveChanges()
at FooBar.<UpdateAccessInformation>d__f.MoveNext() in c:\Users\FooBar\Dropbox\Foo\Foo\Foo\FooBar.cs:line 128
---- Inner Exception ----
Message : An error occurred accessing the database. This usually means that the connection to the database failed. Check that the connection string is correct and that the appropriate DbContext constructor is being used to specify it or find it in the application's config file. See http://go.microsoft.com/fwlink/?LinkId=386386 for information on DbContext and connections. See the inner exception for details of the failure.
Source : EntityFramework
Stack Trace : at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
at System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory)
at System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection)
at System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection)
at System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext)
at System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input)
at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
at System.Data.Entity.Internal.InternalContext.ForceOSpaceLoadingForKnownEntityTypes()
at System.Data.Entity.DbContext.System.Data.Entity.Infrastructure.IObjectContextAdapter.get_ObjectContext()
at System.Data.Entity.Infrastructure.CommitFailureHandler.BeganTransaction(DbConnection connection, BeginTransactionInterceptionContext interceptionContext)
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext,TResult](TTarget target, Func`3 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.BeginTransaction(DbConnection connection, BeginTransactionInterceptionContext interceptionContext)
at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.Core.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel)
---- Inner Exception ----
Message : The provider did not return a ProviderManifestToken string.
Source : EntityFramework
Stack Trace : at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
at System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection)
---- Inner Exception ----
Message : This operation requires a connection to the 'master' database. Unable to create a connection to the 'master' database because the original database connection has been opened and credentials have been removed from the connection string. Supply an unopened connection.
Source : EntityFramework.SqlServer
Stack Trace : at System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act)
at System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection)
at System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection)
---- Inner Exception ----
Message : Login failed for user 'MY_USER_NAME'.
Source : .Net SqlClient Data Provider
Data : Key : HelpLink.ProdName Value : Microsoft SQL Server
Data : Key : HelpLink.EvtSrc Value : MSSQLServer
Data : Key : HelpLink.EvtID Value : 18456
Data : Key : HelpLink.BaseHelpUrl Value : http://go.microsoft.com/fwlink
Data : Key : HelpLink.LinkId Value : 20476
Stack Trace : at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlInternalConnectionTds.CompleteLogin(Boolean enlistOK)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
at System.Data.Entity.Infrastructure.DbExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
at System.Data.Entity.Infrastructure.DbExecutionStrategy.Execute[TResult](Func`1 operation)
at System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act)
at System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act)
---- End of Exception Details ----
```

What would be causing this.

Thanks!

Commented Feature: UpForGrabs: Code First: Easier way to make PK non-clustered (important for GUIDs) [2163]

0
0
I want to Create Guid id as Non-clustered Primary Keys

I find your solution:

Add "clustered" parameter (default true) to PrimaryKey, AddPrimaryKey APIs
Add "clustered" parameter (default false) to Index, CreateIndex APIs
Update Migrations scaffolding to set clustered = false for client-generated GUID primary keys
Update Migrations to use NewSequentialId for store-generated GUID primary keys


But i want to add "clustered" parameter use KeyAttribute or fluent api, instead of PrimaryKey

How this can be done in EF 6.1.0 ?
Thanks.



Comments: Adding a link to duplicate [#2212](http://entityframework.codeplex.com/workitem/2212) here since I like the solution proposed there, that specifying a clustered index on any other column should automatically make the PK non-clustered.

Commented Unassigned: Multiple DbConfiguration instances conflict even when in separate assemblies [2225]

0
0
I have 2 DbContexts (one for company data and the other is for custom identity (asp.net identity via EF).
Each DbContext and related classes are ___in separate assemblies___.
___Each DbContext has its own DbConfiguration___ and I have decorated each DbContext with appropriate attribute (although docs mention that this is not necessary if the DbConfiguration is in the same assembly as the DbContext ?!)

#Issue:
When I run my app and log in it works (identity db context used).
But as soon as I hit part of the app that requires data using company db context I get an exception:

```
A System.InvalidOperationException was thrown:
"An instance of 'MyIdentityDbConfiguration' was set but this type was not discovered in the same assembly as the 'MyCompanyDbContext' context.
Either put the DbConfiguration type in the same assembly as the DbContext type, use DbConfigurationTypeAttribute on the DbContext type to specify the DbConfiguration type, or set the DbConfiguration type in the config file.
See http://go.microsoft.com/fwlink/?LinkId=260883 for more information."
```

Here is briefly the relavant classes in 2 separate assemblies that I have
#1st assembly (MyCompany.Data)

```
[DbConfigurationType(typeof (MyCompanyDbConfiguration))]
[DbModelBuilderVersion(DbModelBuilderVersion.Latest)]
public class MyCompanyDbContext : DbContext
{
//
// ...omitted for brevity
//
}

public class MyCompanyDbConfiguration : DbConfiguration
{
public MyCompanyDbConfiguration()
{
SetDatabaseInitializer(new MyCompanyDbInitializer());
}
}
```

#2nd assembly (MyCompany.Identity)
```
[DbConfigurationType(typeof (MyIdentityDbConfiguration))]
[DbModelBuilderVersion(DbModelBuilderVersion.Latest)]
public class MyIdentityDbContext : IdentityDbContext<MyUser, MyRole, long, MyUserLogin, MyUserRole, MyUserClaim>
{
//
// ...omitted for brevity
//
}


public class MyIdentityDbConfiguration : DbConfiguration
{
public MyIdentityDbConfiguration()
{
SetDatabaseInitializer(new MyIdentityDbInitializer());
}
}
```
Comments: Hello zam6ak, Only one [DbConfiguration](http://msdn.microsoft.com/en-us/data/jj680699.aspx) can be picked to control the behavior of EF per AppDomain and we cannot rely on the order in which assemblies are loaded to pick the one since one of the goals is to be able to use the same configuration at design-time (e.g. Migrations should use the same configuration you use at runtime). The DbConfigurationTypeAttribute is used to facilitate the discovery of your custom configuration but it does not enable loading different configurations in the same application for different context. Depending on what you are trying to achieve it is possible that you can configure a single DbConfiguration to provide alternative behaviors to your two contexts (some of the dependencies you can register in the DbConfiguration can use contextual information to resolve different instances or types, e.g. based on the database provider). It is also commonly a good idea to use the same context in Identity and for the rest of your application.

Closed Unassigned: Multiple DbConfiguration instances conflict even when in separate assemblies [2225]

0
0
I have 2 DbContexts (one for company data and the other is for custom identity (asp.net identity via EF).
Each DbContext and related classes are ___in separate assemblies___.
___Each DbContext has its own DbConfiguration___ and I have decorated each DbContext with appropriate attribute (although docs mention that this is not necessary if the DbConfiguration is in the same assembly as the DbContext ?!)

#Issue:
When I run my app and log in it works (identity db context used).
But as soon as I hit part of the app that requires data using company db context I get an exception:

```
A System.InvalidOperationException was thrown:
"An instance of 'MyIdentityDbConfiguration' was set but this type was not discovered in the same assembly as the 'MyCompanyDbContext' context.
Either put the DbConfiguration type in the same assembly as the DbContext type, use DbConfigurationTypeAttribute on the DbContext type to specify the DbConfiguration type, or set the DbConfiguration type in the config file.
See http://go.microsoft.com/fwlink/?LinkId=260883 for more information."
```

Here is briefly the relavant classes in 2 separate assemblies that I have
#1st assembly (MyCompany.Data)

```
[DbConfigurationType(typeof (MyCompanyDbConfiguration))]
[DbModelBuilderVersion(DbModelBuilderVersion.Latest)]
public class MyCompanyDbContext : DbContext
{
//
// ...omitted for brevity
//
}

public class MyCompanyDbConfiguration : DbConfiguration
{
public MyCompanyDbConfiguration()
{
SetDatabaseInitializer(new MyCompanyDbInitializer());
}
}
```

#2nd assembly (MyCompany.Identity)
```
[DbConfigurationType(typeof (MyIdentityDbConfiguration))]
[DbModelBuilderVersion(DbModelBuilderVersion.Latest)]
public class MyIdentityDbContext : IdentityDbContext<MyUser, MyRole, long, MyUserLogin, MyUserRole, MyUserClaim>
{
//
// ...omitted for brevity
//
}


public class MyIdentityDbConfiguration : DbConfiguration
{
public MyIdentityDbConfiguration()
{
SetDatabaseInitializer(new MyIdentityDbInitializer());
}
}
```
Comments: This is by design, as there can only be one DbConfiguration per application. See the previous comment for more details.

Commented Unassigned: Ignore Abstract DbContext sub-types when using migrations [2215]

0
0
I have an abstract `DbContext` sub-type which I call `RootDbContext`, it's role is calling the `DbContext` constructor to set the connection string name as I have only one for my application; all my concrete contexts inherit from this `RootDbContext`.

When running `Enable-Migrations` a "_More than one context type was found in the assembly '<assembly-name>'_ " error is raised. As my `RootContext` is abstract I thought it was trivial not to be considered by migrations, specifying `-ContextTypeName` each time is a pain. Thanks in advance.
Comments: This was fixed in 6.1.0-alpha1. See [Work Item 1145](https://entityframework.codeplex.com/workitem/1145).

Closed Unassigned: Ignore Abstract DbContext sub-types when using migrations [2215]

0
0
I have an abstract `DbContext` sub-type which I call `RootDbContext`, it's role is calling the `DbContext` constructor to set the connection string name as I have only one for my application; all my concrete contexts inherit from this `RootDbContext`.

When running `Enable-Migrations` a "_More than one context type was found in the assembly '<assembly-name>'_ " error is raised. As my `RootContext` is abstract I thought it was trivial not to be considered by migrations, specifying `-ContextTypeName` each time is a pain. Thanks in advance.
Comments: Duplicate of Work Item 1145

Source code checked in, #644e8cb527c3f5e13ec9be7cf0cce02b8ab86fcb

0
0
I See System Columns Non-updateable, nullable system columns are exposed when reverse engineering a SQL Compact Database that has been provisioned for Merge Replication or by Sync Framework. This fix "hides" those columns - issue #2208
Viewing all 10318 articles
Browse latest View live




Latest Images