I'm using ASP.NET MVC 5 and Identity 2.0
I moved the Identity 2.0 classes (classes defined in Model/IdentityModel.cs and Startup/IdentityConfig.cs) to a class Library because all my models need to reside outside the website, and so does the ApplicationUser class.
After moving the classes I had to install Microsoft.AspNet.Identity.EntityFramework and Microsoft.AspNet.Identity.Owin nuget.
Now when I run the application, I get the following error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace here
I don't really know what went wrong and where. Everything seems to work well till Startup.cs.
I managed to solve it by just deleting the database, and letting EF create a new one for me. The ApplicationDbInitializer's Seed() was called appropriately and everything worked fine.
Related
I'm trying to enable Windows authentication (setting windows mode on authentication) on a huge legacy ASPNET MVC 3 Application, but it isn't working and I can't find why; the Request.IsAuthenticated is always false. The app is very huge and has a lot of personalization with its own authentication and authorization system, but it uses the standard mechanisms of ASPNETMVC to override them (OnAuthorize). I've tried with empty controllers without "personalization" but it doesn't work neither.
I don't know how to start to write here all configuration so, I'm expecting for a genius who could point me to what is wrong...
I've tried too on a sampe new ASPNETMVC3 (from VS2010 templates) and it works fine; I would try to set every thing of my app on this one slowly to try to reproduce if I didn't found any solution before.
--- UPDATE ---
I've copied the web.config and global.asax of template project and it's not working yet. I've added the event WindowsAuthentication_OnAuthenticate on both projects and only enters on the demo project. I can't undersand how, where or why the ASPNET flow is broken.
i have a class library that has my entity framework model and every thing related to it.
the problem is that i am able to access it in my console project but not on MVC project.
The Client throws an open exception :
but when i access any of the entities in context, it throws an Oracle client exception ...
all tasks related to my oracle DB that are not being accessed by entity framework are running all fine on my MVC project
but when it comes to being accesed by EF ... it throws exception : failed to open underlying connection
what can i do to fix this issue? ... i have tried almost everything described in previous such questions
I created a separate Class Library project to store the Database Context and Model Classes.
In the same solution, I created an ASP.NET MVC project and referenced the Class Library project, as well as include the Connection String for the Database Context, in the project's Web.config file.
However, when I attempt to add a Controller (with views, using EF), I get the following error:
Exception has been thrown by the target of an invocation.
I am able to see the Database Context and Model Classes in the Add Controller drop down boxes, so I don't think its a referencing issue.
If anyone is also experiencing this error (with this configuration), you assistance will be greatly appreciated.
I had more than one ConnectionStrings define. I removed the default and replaced it with the ConstringStrings from my Class Library. Works fine now!
Solution taken from the following post: Application can't scaffold items
Yes, In my case, I had the Configuration block declared twice in the Web.config file. After I removed one the scaffolding worked.
I had the same problem until I fixed the version of Microsoft.EntityFrameworkCore to match Microsoft.EntityFrameworkCore.Tools. It was a version mismatch after all!
So I just upgraded my website to a MVC 4 site from MVC 3. My Web host does not have MVC 4 installed but was advised that I can just upload the dlls and all will be alright. I was directed to this link which apparently can be applied when installed
http://weblogs.asp.net/scottgu/archive/2011/01/18/running-an-asp-net-mvc-3-app-on-a-web-server-that-doesn-t-have-asp-net-mvc-3-installed.aspx
I did what is instructed on the following link but then I'm getting an error on my ViewExtensions which apparently (after a 2 hour research) is related to my upgrade (eg. http://s77.codeinspot.com/q/2109234) . Anyway this is the error being thrown.
filterContext.Exception.Message :\hostingpath............... error
CS0121: The call is ambiguous between the following methods or
properties:
'Torneyo.Infrastructure.Helpers.ViewExtensions.AccountProfile(System.Web.Mvc.ViewMasterPage)'
and
'Torneyo.Infrastructure.Helpers.ViewExtensions.AccountProfile(System.Web.Mvc.ViewMasterPage)'
Which doesn't make sense as it's the same and it's just coming from my viewextension class. Following is the part which is being called on my masterpage.
//-----------for master pages
static public User AccountProfile(this System.Web.Mvc.ViewMasterPage view)
{
return (Profile)view.ViewBag.AccountProfile;
}
So these were all working perfectly before the upgrade on the webhost. It runs perfectly on my local before and after the upgrade. I'm not really sure what else I need to do.
Please make sure that you have the correct binding redirects in your web.config. Chances are that parts of the app are referencing MVC3 and other parts are referencing MVC4. A binding redirect from MVC3 to MVC4 will "unify" everything to MVC4.
Check out the "upgrade" guide here: http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806
Finally fixed it. So I tried wiping out the DLLs and reinstalled it but it still doesn't work. What I had to do was to remove everything (Files in the wwwroot folder). And then published it again. Everything worked fine after that.
I have simple scenario:
Web Project(C#) with added dll reference to below DataSource project.
Separate DataSource project (Class Library) where I added edmx file and generated POCOs with DbContext Generator.
Really, nothing special. I think every youtube instructional video I saw on Entity Framework is doing something simple.
What I discovered is that EntityDataSource simply doesn't work. I get range of error messages and I really can't see the pattern when they are showing up:
Here are some:
- Unable to load the specified metadata source
- Schema invalid and types cannot be loaded because the assembly contains EdmSchemaAttribute... loading by both name and attribute is not allowed.
Few time, don't know how, I managed to pass by this error, in that case I would get CLR error when I try to execute simple page with datasource and gridview (nothing was coded)
End to add to the problem...
I am referencing another DataSource project the same way. I am perfectly able to set this EntityDataSource without errors above. But when I click Refresh Schema, I get error "Could not find the CLR type for MyEntity.
What is wrong here.
Thanks
I was getting the EdmSchemaAttribute error message, using EF 5.0 and WCF Data Services 5.2.0. This was a data service using a DbContext-derived class, but the DbContext-derived class was in the same assembly as some EDMX files and ObjectContext-based code generated from the EDMX files.
The fix for me was to separate code-first EF code from model-first EF code (which uses ObjectContext and generates code with the [EdmSchema] attribute). By moving the code-first code into a separate assembly, the error message went away and things are working.
I hope that helps.