2016-04-16 9 views
0

プロジェクトをAzure App Serviceに公開する前に、シードデータなしでVisual Studioでコードファースト移行を実行しました。 6つのテーブルが作成されました:AzureデータベースからIdentityUserデータを取得するときのエラー

  1. dbo._MigrationHistory
  2. dbo.AspNetRoles
  3. dbo.AspNetUserClaims
  4. dbo.AspNetUserLogins
  5. dbo.AspNetUserRoles
  6. dbo.AspNetUsers

は私がcertai場合見つけようとするときWeb.config

2016-04-16T09:58:30 PID[6608] Error 
    at System.Data.SqlClient.SqlConnection.PermissionDemand() 
    at System.Data.SqlClient.SqlConnectionFactory.PermissionDemand(DbConnection outerConnection) 
    at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 
    at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions) 
    at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry) 
    at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry) 
    at System.Data.SqlClient.SqlConnection.Open() 
    at Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext`1.IsIdentityV1Schema(DbContext db) 
    at Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext`1..ctor(String nameOrConnectionString, Boolean throwIfV1Schema) 
    at Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext`1..ctor(String nameOrConnectionString) 
    at authentication.Contexts.AuthContext..ctor() in d:\Projects\learnAuth\authentication\Contexts\AuthContext.cs:line 7 
--- End of stack trace from previous location where exception was thrown --- 
    at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() 
    at System.Data.Entity.Infrastructure.DbContextInfo.CreateInstance() 
    at System.Data.Entity.Infrastructure.DbContextInfo..ctor(Type contextType, DbProviderInfo modelProviderInfo, AppConfig config, DbConnectionInfo connectionInfo, Func`1 resolver) 
    at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration, DbContext usersContext, DatabaseExistenceState existenceState) 
    at System.Data.Entity.Migrations.DbMigrator..ctor(DbMigrationsConfiguration configuration) 
    at System.Data.Entity.MigrateDatabaseToLatestVersion`2.InitializeDatabase(TContext context) 
    at System.Data.Entity.Internal.InternalContext.<>c__DisplayClassf`1.<CreateInitializationAction>b__e() 
    at System.Data.Entity.Internal.InternalContext.PerformInitializationAction(Action action) 
    at System.Data.Entity.Internal.InternalContext.PerformDatabaseInitialization() 
    at System.Data.Entity.Internal.LazyInternalContext.<InitializeDatabase>b__4(InternalContext c) 
    at System.Data.Entity.Internal.RetryAction`1.PerformAction(TInput input) 
    at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabaseAction(Action`1 action) 
    at System.Data.Entity.Internal.LazyInternalContext.InitializeDatabase() 
    at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) 
    at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() 
    at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext() 
    at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider() 
    at System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1 source, Expression`1 predicate, CancellationToken cancellationToken) 
    at System.Data.Entity.QueryableExtensions.FirstOrDefaultAsync[TSource](IQueryable`1 source, Expression`1 predicate) 
    at Microsoft.AspNet.Identity.EntityFramework.UserStore`6.<FindAsync>d__23.MoveNext() 

接続文字列:

<connectionStrings> 
    <add name="AuthContext" connectionString="Server=tcp:seraphtest.database.windows.net,1433;Database=learnauth;User [email protected];Password=XXXXXXXX;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" providerName="System.Data.SqlClient" /> 
</connectionStrings> 

AuthContext.cs

public class AuthContext : IdentityDbContext<IdentityUser> 
{ 
    public AuthContext() : base("AuthContext") { } 
} 

エラーの原因のn IdentityUserが私のコントローラに要求を送信することにより、登録されている、私は次のエラーが発生します:

private UserManager<IdentityUser> userManager; 

public async Task<IdentityUser> Find(UserLoginInfo loginInfo) 
{ 
    // stack trace starts from here 
    IdentityUser user = await userManager.FindAsync(loginInfo); 
    return user; 
} 

このエラーの原因は何ですか?どのように修正できますか?

+0

仕事ができることが判明? –

+0

Azure Portalからコピーされました –

答えて

0

私は

<connectionStrings> 
    <add name="AuthContext" connectionString="Server=tcp:seraphtest.database.windows.net,1433;Database=learnauth;User [email protected];Password=XXXXXXXX;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" providerName="System.Data.SqlClient" /> 
</connectionStrings> 

から

<connectionStrings> 
    <add name="AuthContext" connectionString="Server=tcp:seraphtest.database.secure.windows.net,1433;Database=learnauth;User [email protected];Password=XXXXXXXX;Encrypt=True;TrustServerCertificate=True;Connection Timeout=30;" providerName="System.Data.SqlClient" /> 
</connectionStrings> 
に接続文字列を変更する場合、それはどのようにあなたがあなたの接続文字列を取得するのですか