Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New app from VS template fails #987

Closed
victorhurdugaci opened this issue Oct 30, 2014 · 10 comments
Closed

New app from VS template fails #987

victorhurdugaci opened this issue Oct 30, 2014 · 10 comments
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@victorhurdugaci
Copy link

  1. Create a new WebApp from template in VS
  2. Switch to CoreCLR
  3. Run
  4. Click Register

Expected: everything works out of the box
Actual:

System.Data.SqlClient.SqlException was unhandled by user code
  HResult=-2146232060
  Message=Cannot open database "aspnet5-WebApplication1-fbd89e38-1236-4055-b8fb-0ada0021e17f" requested by the login. The login failed.
Login failed for user 'REDMOND\victorhu'.
  Source=.Net SqlClient Data Provider
  ErrorCode=-2146232060
  _doNotReconnect=false
  Class=11
  LineNumber=65536
  Number=4060
  Procedure=""
  Server=(localdb)\mssqllocaldb
  State=1
  StackTrace:
       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, String newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
       at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, String newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
       at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, String newSecurePassword, Boolean redirectedUserInstance)
       at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, String 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.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
       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 Microsoft.Data.Entity.Relational.RelationalConnection.Open()
       at Microsoft.Data.Entity.Relational.Query.QueryingEnumerable`1.Enumerator.MoveNext()
       at System.Linq.Enumerable.<SelectManyIterator>d__14`2.MoveNext()
       at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
       at Microsoft.Data.Entity.Query.LinqOperatorProvider.<_TrackEntities>d__0`2.MoveNext()
       at Microsoft.Data.Entity.Query.EntityQueryExecutor.EnumerableExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
  InnerException: 

The failure is consistent. It is not a one time only...

EF package: 7.0.0-beta1-11491 (from the release branch)

Code in template:

 public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
    {
        private static bool _created = false;

        public ApplicationDbContext()
        {            
            // Create the database and schema if it doesn't exist
            // This is a temporary workaround to create database until Entity Framework database migrations 
            // are supported in ASP.NET 5
            if (!_created)
            {
                Database.AsRelational().ApplyMigrations(); // <<< This is the line that fails
@rowanmiller
Copy link
Contributor

This could be a result of an issue with first time access to LocalDb, is this the first data access you've done on this install of VS? Could you try running the app again and see if it works?

@victorhurdugaci
Copy link
Author

I tried to run the app many times. Each time I get the same error.

I think @kirthik has the same problem

@divega
Copy link
Contributor

divega commented Oct 30, 2014

@AndriySvyryd, fyi

@AndriySvyryd
Copy link
Member

This could be related to Windows Auth not being supported on CoreCLR.

@rowanmiller rowanmiller added this to the 1.0.0-beta1 milestone Oct 30, 2014
@rowanmiller
Copy link
Contributor

Andriy is investigating for Beta.

@BrennanConroy
Copy link
Member

This seems more like a Tooling issue because this is an internal error that is handled by EF, if you continue past the error it creates the tables and continues running the application perfectly fine.

@AndriySvyryd
Copy link
Member

I agree with Brennan. Some more info:
This also repoes on Desktop CLR
"Enable Just My Code" must be checked
If you press F10 (Step Over) when the exception is displayed VS crashes.

@divega
Copy link
Contributor

divega commented Nov 1, 2014

Thanks @AndriySvyryd for the fix! For some more context on the resolution, here is what he said:

I found the culprit, it’s the temporary SqlClient.

Just My Code allows to break on user-unhandled exceptions (enabled by default), this refers to exceptions that pass through “user code” without being handled.

User code or “My Code” refers to code that is not optimized and has matching pdbs.

We are including the pdbs in the SqlClient package making VS think that’s “My Code”

The fact that this was making VS crash is still concerning. @victorhurdugaci do you think there is some way we can redirect that part to VS?

@victorhurdugaci
Copy link
Author

@mayurid can you please help us identify a VS contact?

@mayurid
Copy link

mayurid commented Nov 3, 2014

Talked to Reshmim and she is working on this.

@AndriySvyryd AndriySvyryd removed their assignment Jun 6, 2018
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
@ajcvickers ajcvickers modified the milestones: 1.0.0-beta1, 1.0.0 Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

7 participants