Case: I have an MVC5 application (basically the MVC5 template with a scaffolded view) with the Google authentication method enabled. The application has been configured to accept email as user name and to store the claims assigned from Google like Surname, givenname, email, nameidentifier, etc, to the membership database (AspNetUserClaims).
When I register and log in with a "local" user everything is fine.
If I log in with a Google user its fine.
If I log in with an account set up to have both a local and external login I get the error below.
I have tried changing the type for the token to different settings using the AntiForgeryConfig option in Application_Start (example)
AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.Email;
But it seems all the Claims are duplicated when combining local and external logins. The strangest thing is that the claims-collection (which I assumed had the answer) is identical for the combined and the external only login.
When logged in as local user these Claims are assigned
[0]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier: a71ff9c0-8dc4-478b-a6f1-2c4cc34b1e46}
[1]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: some#email.com}
[2]: {http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider: ASP.NET Identity}
When logged in with a remote-only or a combined account the claims-list looks like this
[0]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier: 4ab33d77-c2a0-4eff-a759-5cca4323ecbf}
[1]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: some.other#email.com}
[2]: {http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider: ASP.NET Identity}
[3]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier: https://www.google.com/accounts/o8/id?id=AitOGoogleIdentifierRemovedForPrivacygwgwgw}
[4]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress: some.other#email.com}
[5]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname: Other}
[6]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname: Some}
[7]: {http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name: Some Other Person}
Any help will be much appreciated!
Error and stacktrace follows:
Server Error in '/' Application.
Sequence contains more than one matching element
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Sequence contains more than one matching element
Source Error:
Line 10: #using (Html.BeginForm())
Line 11: {
Line 12: #Html.AntiForgeryToken()
Line 13:
Line 14: <div class="form-horizontal">
Source File: x:\someweb\Views\someEntity\Create.cshtml Line: 12
Stack Trace:
[InvalidOperationException: Sequence contains more than one matching element]
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source, Func`2 predicate) +2533810
System.Web.Helpers.AntiXsrf.ClaimUidExtractor.GetUniqueIdentifierParameters(ClaimsIdentity claimsIdentity, String uniqueClaimTypeIdentifier) +701
System.Web.Helpers.AntiXsrf.ClaimUidExtractor.ExtractClaimUid(IIdentity identity) +186
System.Web.Helpers.AntiXsrf.TokenValidator.GenerateFormToken(HttpContextBase httpContext, IIdentity identity, AntiForgeryToken cookieToken) +242
System.Web.Helpers.AntiXsrf.AntiForgeryWorker.GetTokens(HttpContextBase httpContext, AntiForgeryToken oldCookieToken, AntiForgeryToken& newCookieToken, AntiForgeryToken& formToken) +174
System.Web.Helpers.AntiXsrf.AntiForgeryWorker.GetFormInputElement(HttpContextBase httpContext) +109
System.Web.Helpers.AntiForgery.GetHtml() +146
System.Web.Mvc.HtmlHelper.AntiForgeryToken() +39
ASP._Page_Views_Bruker_Create_cshtml.Execute() in x:\prosjekter\Laudi\TFS\Laudi\IWeb\Inspector\Inspector\Views\Bruker\Create.cshtml:12
System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +271
System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +120
System.Web.WebPages.StartPage.RunPage() +63
System.Web.WebPages.StartPage.ExecutePageHierarchy() +100
System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +131
System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) +695
System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) +382
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +431
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +39
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +116
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +529
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +106
System.Web.Mvc.Async.<>c__DisplayClass28.<begininvokeaction>
b__19() +321
System.Web.Mvc.Async.<>c__DisplayClass1e.<begininvokeaction>
b__1b(IAsyncResult asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
System.Web.Mvc.Controller.<beginexecutecore>
b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.<beginexecute>
b__15(IAsyncResult asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.MvcHandler.<beginprocessrequest>
b__4(IAsyncResult asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9688704
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
The behavior is normal as you can see from the following method (called when creating the user identity):
await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie)
in SignInAsync method.
In the implementation of CreateIdentityAsync:
...
ClaimsIdentity claimsIdentity = new ClaimsIdentity(authenticationType, this.UserNameClaimType, this.RoleClaimType);
claimsIdentity.AddClaim(new Claim(this.UserIdClaimType, user.Id, "http://www.w3.org/2001/XMLSchema#string"));
claimsIdentity.AddClaim(new Claim(this.UserNameClaimType, user.UserName, "http://www.w3.org/2001/XMLSchema#string"));
claimsIdentity.AddClaim(new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider", "ASP.NET Identity", "http://www.w3.org/2001/XMLSchema#string"));
if (manager.SupportsUserRole)
{
foreach (string rolesAsync in await manager.GetRolesAsync(user.Id))
{
claimsIdentity.AddClaim(new Claim(this.RoleClaimType, rolesAsync, "http://www.w3.org/2001/XMLSchema#string"));
}
}
if (manager.SupportsUserClaim)
{
claimsIdentity.AddClaims(await manager.GetClaimsAsync(user.Id));
}
...
As you can see there are three claims added by default. To them are added your "custom" claims. This is why you'll have duplicated claims, meaning that SingleOrDefault call on the claims collection will throw the error that you've mentioned.
As a solution you can either use other claims either update them, after the identity creation, it's up to your business need.
Related
I'm using the DancingGoatMVC sample of Kentico.
Now I'm testing if I can add an Article page using the api.
Basically I added new method to the article controller and views.
As you can see I'm already populating the DocumentName but the error is still occurring, any ideas to solve this error and what I might be missing that is causing this issue?
Thanks
Controllers:
public ActionResult Add()
{
return View();
}
[HttpPost]
public ActionResult Add(ArticleViewModel articleViewModel)
{
// Creates a new instance of the Tree provider
TreeProvider tree = new TreeProvider(MembershipContext.AuthenticatedUser);
// Gets the current site's root "/" page, which will serve as the parent page
TreeNode parentPage = tree.SelectNodes()
.Path("/Articles")
.OnCurrentSite()
.Culture("en-us")
.FirstObject;
if (parentPage.DocumentName != null)
{
TreeNode newPage = TreeNode.New(SystemDocumentTypes.Root,
tree);
// Sets the properties of the new page
newPage.DocumentName = "Articles";
newPage.DocumentCulture = "en-us";
newPage.SetValue("Title", "test");
newPage.SetValue("Summary", "test");
newPage.SetValue("Text", "test");
newPage.SetValue("DocumentName", "Articles");
// Inserts the new page as a child of the parent page
newPage.Insert(parentPage,true);
}
return RedirectToAction("Index");
}
Error:
Server Error in '/Kentico12_DancingGoatMvc' Application.
The DocumentName value is not specified.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Exception: The DocumentName value is not specified.
Source Error:
Line 90: newPage.SetValue("DocumentName", "Articles");
Line 91: // Inserts the new page as a child of the parent page
Line 92: newPage.Insert(parentPage,true);
Line 93: }
Line 94:
Source File: C:\inetpub\wwwroot\Kentico12\DancingGoatMvc\Controllers\ArticlesController.cs Line: 92
Stack Trace:
[Exception: The DocumentName value is not specified.]
CMS.DocumentEngine.TreeNode.InsertNode(TreeNode parent) in D:\CMS\MAIN\CMSSolution\DocumentEngine\Documents\TreeNode.cs:4008
CMS.DocumentEngine.TreeNode.Insert(TreeNode parent, Boolean useDocumentHelper) in D:\CMS\MAIN\CMSSolution\DocumentEngine\Documents\TreeNode.cs:3959
CMS.DocumentEngine.DocumentHelper.InsertDocument(TreeNode node, TreeNode parentNode, TreeProvider tree, Boolean allowCheckOut) in D:\CMS\MAIN\CMSSolution\DocumentEngine\DocumentHelper.cs:457
CMS.DocumentEngine.TreeNode.Insert(TreeNode parent, Boolean useDocumentHelper) in D:\CMS\MAIN\CMSSolution\DocumentEngine\Documents\TreeNode.cs:3946
DancingGoat.Controllers.ArticlesController.Add(ArticleViewModel articleViewModel) in C:\inetpub\wwwroot\Kentico12\DancingGoatMvc\Controllers\ArticlesController.cs:92
lambda_method(Closure , ControllerBase , Object[] ) +139
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +229
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +35
System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +39
System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +77
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +72
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +387
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +387
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +387
System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +387
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +38
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +188
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +52
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +43
System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +602
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +195
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +128
This line here appears to be the problem:
newPage.SetValue("DocumentName", "Articles")
Why are you assigning it like this when you're already assigning it above?
Secondly, is your DocumentName property based on another required property of the page type like Title? You can see this under the Fields definition of the page type. The dropdown will be directly under the Field names box.
I got an issue trying to set up Asp.Net Identity 2.1 with MVC5 and have installed the entity Framework 6.1.2 libraries. But when I run the application and try and get this to for example register a user I get the following error;
Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.
[TypeLoadException: Could not load type 'System.ComponentModel.DataAnnotations.Schema.IndexAttribute' from assembly 'EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.] Microsoft.AspNet.Identity.EntityFramework.IdentityDbContext`6.OnModelCreating(DbModelBuilder modelBuilder) +0 System.Data.Entity.Internal.LazyInternalContext.CreateModelBuilder() +375 System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +15 System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +123 System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +602 System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +18 System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +53 System.Data.Entity.Internal.Linq.InternalSet`1.Include(String path) +18 System.Data.Entity.Infrastructure.DbQuery`1.Include(String path) +66 System.Data.Entity.QueryableExtensions.Include(IQueryable`1 source, String path) +130 System.Data.Entity.QueryableExtensions.Include(IQueryable`1 source, Expression`1 path) +181 Microsoft.AspNet.Identity.EntityFramework.UserStore`6.GetUserAggregateAsync(Expression`1 filter) +609 Microsoft.AspNet.Identity.EntityFramework.UserStore`6.FindByNameAsync(String userName) +1072 Microsoft.AspNet.Identity.UserManager`2.FindByNameAsync(String userName) +178 Microsoft.AspNet.Identity.Owin.<PasswordSignInAsync>d__29.MoveNext() +217 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24 TestID.Controllers.<Login>d__2.MoveNext() in f:\CodeSamples\IDClaims\TestID\TestID\Controllers\AccountController.cs:78 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52 System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21 System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +61 System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +114 System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +66 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49 System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d() +117 System.Web.Mvc.Async.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +323 System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +44 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50 System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +72 System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +185 System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56 System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40 System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44 System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39 System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70 System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59 System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40 System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9657896 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
The error indicates that I am using Entity Framework Version 6.0.0 which has a feature only available in Version 6.1 onwards. I have checked my project references and all my references point to Version 6.1.2, not sure what I am doing wrong?
I have installed Visual Studio Update 4 and Web Essentials 2013 and regardless if I set up a new project I get the same issue. I have reinstalled the nuget packages through the command line a number of times and have cleared out my cache from the following directory;
Delete all files from the following folders and try again:
C:\Users\[username]\AppData\Local\Temp\Temporary ASP.NET Files\ %SystemRoot%\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\ %SystemRoot%\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\ %SystemRoot%\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\ %SystemRoot%\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\
But still get the same problem, I am using ASP.Net Identity 2.1.0 and Entity Framework 6.1.2 and package.config point to the correct versions and references point to the correct package directory and project references point to the correct reference directory of Entity 6.1.2. emmm.....
Even if I go into Object Browser I can see the IndexAttribute method in the System.ComponentModel.Data.Annotation.Schema.
One thing that does look odd to me is that in .NET Reflector Object Browser the Entity Framework assembly looks like 6.0.0.0 not sure why when all references are looking at 6.1.2.
Any assistance would be appreciated. :O)
This question has been asked a few times, but never been answered, so hopefully we can get it answered now.
I have an existing project with numerous contract classes and EF6 data access projects all used from my MVC5 web project.
I want to use glimpse, so I installed glimpse on my MVC web project.
However after doing so, I keep getting the following error:
Unable to determine the provider name for provider factory of type
'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET
provider is installed or registered in the application config.
When I uninstall glimpse, it all works again. Now after doing some googling it will seem that this is an issue out there, but I cannot find anywhere that someone addresses it with a definitive answer, and every suggestion that I have tried, have not fixed it.
I had glimpse installed before when I was still using EF5, and it all worked without any issues, but I have not had any luck since moving to EF6.
Hopefully it is a small configuration I am missing.
Any help is appreciated.
STACKTRACE
[NotSupportedException: Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.]
System.Data.Entity.Utilities.DbProviderFactoryExtensions.GetProviderInvariantName(DbProviderFactory factory) +290
System.Data.Entity.Infrastructure.DependencyResolution.DefaultInvariantNameResolver.GetService(Type type, Object key) +248
System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k) +75
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +72
System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.GetService(Type type, Object key) +210
System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) +60
System.Linq.WhereSelectArrayIterator`2.MoveNext() +66
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +161
System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key) +250
System.Data.Entity.Infrastructure.DependencyResolution.RootDependencyResolver.GetService(Type type, Object key) +106
System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) +60
System.Linq.WhereSelectArrayIterator`2.MoveNext() +66
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +94
System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key) +250
System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key) +102
System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService(IDbDependencyResolver resolver, Object key) +145
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInvariantName(DbConnection connection) +71
System.Data.Entity.Core.EntityClient.EntityConnection.get_ConnectionString() +343
System.Data.Entity.Internal.InternalConnection.GetStoreConnectionString(DbConnection connection) +54
System.Data.Entity.Internal.InternalConnection.OnConnectionInitialized() +71
System.Data.Entity.Internal.EagerInternalConnection..ctor(DbConnection existingConnection, Boolean connectionOwned) +61
System.Data.Entity.DbContext..ctor(DbConnection existingConnection, Boolean contextOwnsConnection) +94
......Forms.EFModel.FormsEntities..ctor(DbConnection connection) in d:\.....\.....Online\Main\Source\Web\......Forms.EFModel\_FormsEntities.cs:10
......Forms.EFModel.FormsWorkspace.<CreateUnitOfWork>b__0(DbConnection c) in d:\.....\.....Online\Main\Source\Web\......Forms.EFModel\FormsWorkspace.cs:19
......Common.EntityFramework.EntityUnitOfWork`1.get_Context() in d:\.....\.....Online\Main\Source\Web\......Common.EntityFramework\EntityUnitOfWork.cs:66
......Forms.Repositories.FormsBaseRepository.GetForms(IEnumerable`1 formNumbers, FormStatusGroup statusGroup, Nullable`1 formType, Permission permission) in d:\.....\.....Online\Main\Source\Web\......Forms\Repositories\_FormsBaseRepository_IForms.cs:87
......Mvc.Areas.Me.Controllers.HomeController.AdviserSummary(String id) in d:\.....\.....Online\Main\Source\Web\......Mvc\Areas\Me\Controllers\HomeController.cs:148
......Mvc.Areas.Me.Controllers.HomeController.Index() in d:\.....\.....Online\Main\Source\Web\......Mvc\Areas\Me\Controllers\HomeController.cs:59
lambda_method(Closure , ControllerBase , Object[] ) +101
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +59
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +434
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +60
System.Web.Mvc.Async.ActionInvocation.InvokeSynchronousActionMethod() +76
System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__36(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +36
System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +73
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3c() +117
System.Web.Mvc.Async.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() +323
System.Web.Mvc.Async.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() +323
System.Web.Mvc.Async.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() +323
System.Web.Mvc.Async.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() +323
System.Web.Mvc.Async.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() +323
System.Web.Mvc.Async.<>c__DisplayClass45.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3e() +323
System.Web.Mvc.Async.<>c__DisplayClass30.<BeginInvokeActionMethodWithFilters>b__2f(IAsyncResult asyncResult) +44
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
System.Web.Mvc.Async.<>c__DisplayClass28.<BeginInvokeAction>b__19() +72
System.Web.Mvc.Async.<>c__DisplayClass1e.<BeginInvokeAction>b__1b(IAsyncResult asyncResult) +185
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__4(IAsyncResult asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9690164
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
EDIT: stack trace added at bottom.
I have an ASP.NET MVC 5 project that uses a SQL Server database via Entity Framework 6.
I added Glimpse (and Glimpse.MVC5) to the project, and that works fine.
However, when I add Glimpse.EF6, my application throws an exception as soon as it attempts to access the database. The exception is:
System.NotSupportedException
Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.
What's going on? FYI, the connectionStrings part of my web.config looks like this:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=.; Initial Catalog=foo; Integrated Security=True; MultipleActiveResultSets=True;" providerName="System.Data.SqlClient" />
</connectionStrings>
...and my Application_Start method looks like this:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
GlobalConfiguration.Configure(WebApiConfig.Register);
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
Database.SetInitializer(new WebApplication.Models.Storage.ApplicationDbInitializer());
}
...and my context class looks like this:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext()
: base("DefaultConnection")
{
}
public DbSet<Foo> Foos { get; set; }
}
Thanks in advance for any help...
STACK TRACE:
[NotSupportedException: Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.]
System.Data.Entity.Utilities.DbProviderFactoryExtensions.GetProviderInvariantName(DbProviderFactory factory) +290
System.Data.Entity.Infrastructure.DependencyResolution.DefaultInvariantNameResolver.GetService(Type type, Object key) +248
System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass1.<GetService>b__0(Tuple`2 k) +75
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +72
System.Data.Entity.Infrastructure.DependencyResolution.CachingDependencyResolver.GetService(Type type, Object key) +210
System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) +60
System.Linq.WhereSelectArrayIterator`2.MoveNext() +66
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +161
System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key) +250
System.Data.Entity.Infrastructure.DependencyResolution.RootDependencyResolver.GetService(Type type, Object key) +106
System.Data.Entity.Infrastructure.DependencyResolution.<>c__DisplayClass3.<GetService>b__0(IDbDependencyResolver r) +60
System.Linq.WhereSelectArrayIterator`2.MoveNext() +66
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +94
System.Data.Entity.Infrastructure.DependencyResolution.ResolverChain.GetService(Type type, Object key) +250
System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(Type type, Object key) +102
System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService(IDbDependencyResolver resolver, Object key) +145
System.Data.Entity.Core.Common.<>c__DisplayClass5.<GetExecutionStrategy>b__4(ExecutionStrategyKey k) +84
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +72
System.Data.Entity.Core.Common.DbProviderServices.GetExecutionStrategy(DbConnection connection, DbProviderFactory providerFactory) +351
System.Data.Entity.Core.Common.DbProviderServices.GetExecutionStrategy(DbConnection connection) +62
System.Data.Entity.SqlServer.SqlProviderServices.UsingConnection(DbConnection sqlConnection, Action`1 act) +319
System.Data.Entity.SqlServer.SqlProviderServices.UsingMasterConnection(DbConnection sqlConnection, Action`1 act) +335
System.Data.Entity.SqlServer.SqlProviderServices.GetDbProviderManifestToken(DbConnection connection) +399
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +132
[ProviderIncompatibleException: The provider did not return a ProviderManifestToken string.]
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +327
Glimpse.EF.AlternateType.GlimpseDbProviderServices.GetDbProviderManifestToken(DbConnection connection) +113
System.Data.Entity.Core.Common.DbProviderServices.GetProviderManifestToken(DbConnection connection) +255
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +67
[ProviderIncompatibleException: 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.]
System.Data.Entity.Utilities.DbProviderServicesExtensions.GetProviderManifestTokenChecked(DbProviderServices providerServices, DbConnection connection) +277
System.Data.Entity.Infrastructure.<>c__DisplayClass1.<ResolveManifestToken>b__0(Tuple`3 k) +63
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +72
System.Data.Entity.Infrastructure.DefaultManifestTokenResolver.ResolveManifestToken(DbConnection connection) +360
System.Data.Entity.Utilities.DbConnectionExtensions.GetProviderInfo(DbConnection connection, DbProviderManifest& providerManifest) +89
System.Data.Entity.DbModelBuilder.Build(DbConnection providerConnection) +79
System.Data.Entity.Internal.LazyInternalContext.CreateModel(LazyInternalContext internalContext) +143
System.Data.Entity.Internal.RetryLazy`2.GetValue(TInput input) +171
System.Data.Entity.Internal.LazyInternalContext.InitializeContext() +594
System.Data.Entity.Internal.InternalContext.Initialize() +31
System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType) +39
System.Data.Entity.Internal.Linq.InternalSet`1.Initialize() +138
System.Data.Entity.Internal.Linq.InternalSet`1.Include(String path) +41
System.Data.Entity.Infrastructure.DbQuery`1.Include(String path) +142
System.Data.Entity.QueryableExtensions.Include(IQueryable`1 source, String path) +205
System.Data.Entity.QueryableExtensions.Include(IQueryable`1 source, Expression`1 path) +305
Microsoft.AspNet.Identity.EntityFramework.UserStore`6.GetUserAggregateAsync(Expression`1 filter) +610
Microsoft.AspNet.Identity.EntityFramework.UserStore`6.FindByNameAsync(String userName) +1070
Microsoft.AspNet.Identity.<FindByNameAsync>d__10.MoveNext() +283
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.ConfiguredTaskAwaiter.GetResult() +24
Microsoft.AspNet.Identity.<FindAsync>d__18.MoveNext() +673
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24
WebApplication.Controllers.<Login>d__2.MoveNext() in c:\Users\Gary\Documents\Visual Studio 2013\Projects\eByGum\WebApplication\Controllers\AccountController.cs:49
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
System.Threading.Tasks.TaskHelpersExtensions.ThrowIfFaulted(Task task) +61
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult) +114
System.Web.Mvc.Async.<>c__DisplayClass37.<BeginInvokeAsynchronousActionMethod>b__36(IAsyncResult asyncResult) +66
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +49
Castle.Proxies.AsyncControllerActionInvokerProxy.EndInvokeActionMethod_callback(IAsyncResult asyncResult) +42
Castle.Proxies.Invocations.AsyncControllerActionInvoker_EndInvokeActionMethod.InvokeMethodOnTarget() +103
Castle.DynamicProxy.AbstractInvocation.Proceed() +117
Glimpse.Core.Extensibility.CastleInvocationToAlternateMethodContextAdapter.Proceed() +48
Glimpse.Mvc.AlternateType.EndInvokeActionMethod.NewImplementation(IAlternateMethodContext context) +152
Glimpse.Core.Extensibility.AlternateTypeToCastleInterceptorAdapter.Intercept(IInvocation invocation) +183
Castle.DynamicProxy.AbstractInvocation.Proceed() +483
Castle.Proxies.AsyncControllerActionInvokerProxy.EndInvokeActionMethod(IAsyncResult asyncResult) +203
System.Web.Mvc.Async.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f() +117
System.Web.Mvc.Async.<>c__DisplayClass48.<InvokeActionMethodFilterAsynchronouslyRecursive>b__41() +323
System.Web.Mvc.Async.<>c__DisplayClass33.<BeginInvokeActionMethodWithFilters>b__32(IAsyncResult asyncResult) +44
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +47
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +136
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +102
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +50
System.Web.Mvc.Async.<>c__DisplayClass2b.<BeginInvokeAction>b__1c() +72
System.Web.Mvc.Async.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult) +184
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +133
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +56
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +40
System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +34
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +44
System.Web.Mvc.Controller.<BeginExecute>b__15(IAsyncResult asyncResult, Controller controller) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +62
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +39
System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +39
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +70
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +139
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +59
System.Web.Mvc.Async.AsyncResultWrapper.End(IAsyncResult asyncResult, Object tag) +40
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +40
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +38
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +9514812
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
For those of you looking for a workaround:
It looks like it's a bug within EF itself (it was mentioned as 173 above, but the link is correct). You can either wait for EF 6.1.1/6.2 or you can downgrade to EF 6.0.2 and it will start to work again.
In the Package Manager Console, type this:
Install-Package EntityFramework -Version 6.0.2
and you should be good to go.
But only if EF 6.0.2 is an option for you. Good luck.
In case of having problem like Eric Sassaman had, working with Glimpse and seems to hosed your project. Make sure after glimpse remove (from nuget) you've removed all dll's from the bin directory.
In my case, Azure build was caching glimpse dll's which made an error like:
[NotSupportedException: Unable to determine the provider name for provider factory of type 'System.Data.SqlClient.SqlClientFactory'. Make sure that the ADO.NET provider is installed or registered in the application config.]
Try adding the below to your config file
<configuration>
<configSections>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
</providers>
</entityFramework>
</configuration>
We're using Orchard 1.6 with the Secured Sockets Layer 1.2 module and the Authentication.Federated 0.2 module. On many of the requests, we get various transaction errors. Here's an example of one that keeps cropping up:
[TransactionAbortedException: The transaction has aborted.]
System.Transactions.TransactionStateAborted.CreateAbortingClone(InternalTransaction tx) +17
System.Transactions.DependentTransaction..ctor(IsolationLevel isoLevel, InternalTransaction internalTransaction, Boolean blocking) +205
System.Transactions.Transaction.DependentClone(DependentCloneOption cloneOption) +208
System.Transactions.TransactionScope.SetCurrent(Transaction newCurrent) +152
System.Transactions.TransactionScope..ctor(TransactionScopeOption scopeOption, TransactionOptions transactionOptions) +994
Orchard.Data.TransactionManager.Orchard.Data.ITransactionManager.Demand() in C:\Projects\MySite\src\Orchard\Data\TransactionManager.cs:37
Orchard.Data.SessionLocator.For(Type entityType) in C:\Projects\MySite\src\Orchard\Data\SessionLocator.cs:31
Orchard.ContentManagement.DefaultContentManager.GetManyImplementation(QueryHints hints, Action`2 predicate) in C:\Projects\MySite\src\Orchard\ContentManagement\DefaultContentManager.cs:301
Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in C:\Projects\MySite\src\Orchard\ContentManagement\DefaultContentManager.cs:140
Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options) in C:\Projects\MySite\src\Orchard\ContentManagement\DefaultContentManager.cs:111
Orchard.ContentManagement.DefaultContentManager.Get(Int32 id) in C:\Projects\MySite\src\Orchard\ContentManagement\DefaultContentManager.cs:107
Orchard.Security.Providers.FormsAuthenticationService.GetAuthenticatedUser() in C:\Projects\MySite\src\Orchard\Security\Providers\FormsAuthenticationService.cs:94
Orchard.Security.CurrentUserWorkContext.<Get>b__0(WorkContext ctx) in C:\Projects\MySite\src\Orchard\Security\CurrentUserWorkContext.cs:13
Orchard.Environment.<>c__DisplayClass5`1.<FindResolverForState>b__3() in C:\Projects\MySite\src\Orchard\Environment\WorkContextImplementation.cs:37
Orchard.Environment.WorkContextImplementation.GetState(String name) in C:\Projects\MySite\src\Orchard\Environment\WorkContextImplementation.cs:28
Orchard.WorkContext.get_CurrentUser() in C:\Projects\MySite\src\Orchard\WorkContext.cs:60
Orchard.Security.Authorizer.Authorize(Permission permission, IContent content, LocalizedString message) in C:\Projects\MySite\src\Orchard\Security\Authorizer.cs:72
Orchard.Security.Authorizer.Authorize(Permission permission) in C:\Projects\MySite\src\Orchard\Security\Authorizer.cs:60
Orchard.Security.SecurityFilter.OnAuthorization(AuthorizationContext filterContext) in C:\Projects\MySite\src\Orchard\Security\SecurityFilter.cs:24
System.Web.Mvc.ControllerActionInvoker.InvokeAuthorizationFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor) +156
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +854224
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +40
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51
Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in C:\Projects\MySite\src\Orchard\Mvc\Routes\ShellRoute.cs:162
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
This question seems to indicate that this is an issue with the ambient transactions and should hopefully get resolved in 1.7. However, is there something we can do to address these issues in 1.6?
EDIT: Here's another one we keep getting:
[InvalidOperationException: The connection object can not be enlisted in transaction scope.]
System.Data.SqlServerCe.SqlCeConnection.Enlist(Transaction tx) +199
System.Data.SqlServerCe.SqlCeConnection.Open() +403
NHibernate.Connection.DriverConnectionProvider.GetConnection() +238
NHibernate.AdoNet.ConnectionManager.GetConnection() +95
NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd) +43
[ADOException: While preparing SELECT this_.Id as Id248_3_, this_.Number as Number248_3_, this_.Published as Published248_3_, this_.Latest as Latest248_3_, this_.Data as Data248_3_, this_.ContentItemRecord_id as ContentI6_248_3_, contentite1_.Id as Id247_0_, contentite1_.Data as Data247_0_, contentite1_.ContentType_id as ContentT3_247_0_, sitesettin4_.Id as Id253_1_, sitesettin4_.SiteSalt as SiteSalt253_1_, sitesettin4_.SiteName as SiteName253_1_, sitesettin4_.SuperUser as SuperUser253_1_, sitesettin4_.PageTitleSeparator as PageTitl5_253_1_, sitesettin4_.HomePage as HomePage253_1_, sitesettin4_.SiteCulture as SiteCult7_253_1_, sitesettin4_.ResourceDebugMode as Resource8_253_1_, sitesettin4_.PageSize as PageSize253_1_, sitesettin4_.SiteTimeZone as SiteTim10_253_1_, contenttyp5_.Id as Id250_2_, contenttyp5_.Name as Name250_2_ FROM Orchard_Framework_ContentItemVersionRecord this_ inner join Orchard_Framework_ContentItemRecord contentite1_ on this_.ContentItemRecord_id=contentite1_.Id left outer join Settings_SiteSettingsPartRecord sitesettin4_ on contentite1_.Id=sitesettin4_.Id left outer join Orchard_Framework_ContentTypeRecord contenttyp5_ on contentite1_.ContentType_id=contenttyp5_.Id WHERE contentite1_.Id = #p0 and this_.Published = #p1 ORDER BY GETDATE() OFFSET 0 ROWS FETCH NEXT #p2 ROWS ONLY an error occurred]
NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd) +390
NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) +84
NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) +600
NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +273
NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) +205
NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) +425
NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) +23
NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session) +60
NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) +1055
NHibernate.Impl.CriteriaImpl.List(IList results) +63
NHibernate.Impl.CriteriaImpl.List() +79
Orchard.ContentManagement.DefaultContentManager.GetManyImplementation(QueryHints hints, Action`2 predicate) in C:\Projects\MySite\src\Orchard\ContentManagement\DefaultContentManager.cs:334
Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in C:\Projects\MySite\src\Orchard\ContentManagement\DefaultContentManager.cs:140
Orchard.ContentManagement.ContentGetExtensions.Get(IContentManager manager, Int32 id, VersionOptions options, QueryHints hints) in C:\Projects\MySite\src\Orchard\ContentManagement\ContentExtensions.cs:160
Orchard.Core.Settings.Services.SiteService.GetSiteSettings() in C:\Projects\MySite\src\Orchard.Web\Core\Settings\Services\SiteService.cs:46
Orchard.Settings.CurrentSiteWorkContext.Get(String name) in C:\Projects\MySite\src\Orchard\Settings\CurrentSiteWorkContext.cs:13
Orchard.Environment.<>c__DisplayClass5`1.<FindResolverForState>b__0(IWorkContextStateProvider wcsp) in C:\Projects\MySite\src\Orchard\Environment\WorkContextImplementation.cs:32
System.Linq.WhereSelectArrayIterator`2.MoveNext() +82
System.Linq.Enumerable.FirstOrDefault(IEnumerable`1 source, Func`2 predicate) +215
Orchard.Environment.WorkContextImplementation.FindResolverForState(String name) in C:\Projects\MySite\src\Orchard\Environment\WorkContextImplementation.cs:32
System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey key, Func`2 valueFactory) +83
Orchard.Environment.WorkContextImplementation.GetState(String name) in C:\Projects\MySite\src\Orchard\Environment\WorkContextImplementation.cs:27
Orchard.WorkContext.get_CurrentSite() in C:\Projects\MySite\src\Orchard\WorkContext.cs:52
Contrib.SecuredSocketsLayer.Filters.SecuredSocketsLayersFilter.OnActionExecuting(ActionExecutingContext filterContext) +231
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +72
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +854290
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +309
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +854224
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__19() +40
System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +15
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +65
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +51
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +42
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +15
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +51
Orchard.Mvc.Routes.HttpAsyncHandler.EndProcessRequest(IAsyncResult result) in C:\Projects\MySite\src\Orchard\Mvc\Routes\ShellRoute.cs:162
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288
EDIT2: Took the SSL module out of the mix by disabling it and am just accessing over SSL at all times. (Doesn't solve the issue, but does show that this issue occurs with just the Auth.Fed module.)
EDIT3: I tried putting suppression code around each method in the Auth.Fed module, but it didn't help. (Causes issues on the Authenticate due to nested transactions, which made me think that might be where the issue was, but then I was able to reproduce before getting to that step, so doesn't seem to be it.)