Code First Migrations is enabled for context 'ApplicationDbContext' but the database does not exist - ef-code-first

I migrated this application and it's database to a production server. In fact within the production environment it runs fine in debug mode... but when I deploy it I get this error. This is a common error with EF Code First but none of the usual fixes have worked. Any help or suggestions would be greatly appreciated!

I would delete the question but have added the answer as it was a strange circumstance that was difficult to figure out. I think it will rarely happen to others as I have only seen one or two other similar circumstances across the web... but am posting just in case it can help someone else out. I figured it out by deploying a different ASP application to the same application pool which gave a different exception: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible.
After researching this I saw a circumstance where someone suggested giving the IIS USER the DB Owner role within the corresponding SQL Server Login. I did it as a last ditched effort and amazingly it worked! After doing this I re-deployed the original MVC application that was producing the error above and it worked fine.
Thanks for taking the time to look at this.

Related

BizTalk CU2 update giving error and not complete properly

Can anyone tell me why I'm getting the following error when installing BizTalk 2013 R2 CU2:
BtsDeploySystemAssemblyTask has stopped working
I might have had this same problem recently and the solution was to run the update as a different user that had more permissions and it worked.
Since the error is coming up through the SqlClient, you need to make sure the running user has high level permissions to all the databases or even the entire SQL Server Instance.
Sorry :( but since it was a single event, we had no opportunity to repro or investigate though the successful user was a fully sysadmin on SQL Server and Domain Administrator.

IISRESET windows 10 (IIS 10) Access denied

I'm just wondering, why I get error during an iisreset in my development machine.
When I execute the command in a Command Prompt some times it wokrs,sometimes it throws an Access Denied Error, and sometimes it throws a file not found exception.
If anyone finds a solution to this anoying problem, I would appreciate a hint how to get rid of it.
In the IIS I'm just hosting an .NET 4.6.1 MVC site.
This stupid error happens randomly and was very annoying especially when you place iisreset inside a script and assume it will do its thing; took me a while to figure it out. It is not related to the service being stopped as can be seen in this picture:
The only thing I use now is:
net stop W3SVC
and
net start W3SVC
Haven't had a problem since then.
I got exactly the same error time ago. Running it in German too. Take a look at this article: https://techcommunity.microsoft.com/t5/iis-support-blog/iis-reset-issue-restart-attempt-failed/ba-p/1031976
Judging from #Giorgi Nakeuri's question about the event logs. The "World Wide Web Publishing" (called only "WWW-Publishingdienst" in German) is very likely not running. You need to start it. The "Windows activity process service" fails because of the first one failing.
I think it says that he was unable to start the service, mainly due to a Problem with authorization. The solution of the problem can be provided in several different ways
1- Configuration causing the authorization error can be corrected
applicationHost.config with XML
2- This authorization can be revoked through the Windows register. Example approach here:
https://stackoverflow.com/a/21036837/914284
3- Machine configuration can be changed in accordance with this
permission. Please continue with the option that suits you :)
https://knowledge.digicert.com/solution/SO1360
i hope it will resolve
Specifying the machine name also helps in some scenarios:
iisreset %ComputerName%

StackOverflow error when calling DataContext.SubmitChanges()

In a hybrid asp.net web application, framework 4.5.1, using LINQ to SQL (not Entity Framework) I'm getting the exception
"An unhandled exception of type 'System.StackOverflowException' occurred in System.Data.Linq.dll"
on any call to DataContext.SubmitChanges().
Every call to SubmitChanges() causes the error, it does not matter what specific entity is being altered. The error is thrown immediately (unlike most StackOverflow exceptions, which normally take a few seconds to occur while the errant code overflows the stack).
The asp.net web application is running on my local host in IIS express using Visual Studio 2013. The database is SQL Server 2005.
My question is, how does one debug a StackOverflow exception in this environment? Right now the above error message is all I get.
The Event Viewer notes that the browser crashed (it happens in both IE 11 and Chrome) but nothing about the LINQ to SQL exception.
The SQL Server process monitor does not register any database call.
I have a log hooked up to my DataContext but it records nothing.
It appears the stack overflow is happening inside System.Data.dll before any database call occurs and before anything can be logged.
This suddenly started happening several hours ago, after a windows update ran and the machine rebooted. That might be a coincidence.
Something else extremely odd: we have four developers in our shop, all using Visual Studio 2013. Two of us suddenly began having this problem, and two of us never had it. We're all running identical code and hitting the same database. The two of us having the problem rebooted, and the problem disappeared on one machine, but is still occurring on my machine.
In addition to rebooting, I've deleted the project from machine and pulled it down from source control so that it is identical to what my 3 co-workers have, deleted all temporary internet files on my machine, and deleted all of my AppData\Local\temp files for my login.
Is there any way to debug this issue?
Clip of call stack when exception occurs (the calls to VisitExpression and etc repeat many dozens of times until it ends).
The unsatisfying "answer" in this case was to delete the *.dbml file and re-create it. That fixed the stack overflow error.
My comment in reply to #GertArnold above was not accurate. Only one DataContext was throwing the stack overflow exception. It was doing it for every entity in the DataContext, but other DataContexts in the application were working properly.
This particular *.dbml file has been growing over the years to gargantuan size. While re-creating I was careful to only add database objects that are being referenced, which resulted in a much smaller *.dbml file, which might itself have fixed the problem.
Thanks a lot Tom for the info!
Just in case other people may hit the same problem, here is extra info from my case. I have got a very similar issue after my PC got a batch of Windows updates yesterday, the updates including windows10 OS, VS2013/VS2015 and etc. I primarily use VS2013, some differences with Tom's case are,
it only pops up when update one entity, other entities in the same DataContext work fine
only affects my ASP.NET Web API project, console applications are fine, even all app projects ref to the same unitofwork data layer project (in where the dbml file sits)
replacing the dbml file didn't work for me, I finally solved it by opening the solution in VS2015 >> debugging >> closing VS2015 >> opening the solution in VS2013, the problem just disappeared

Server Configuration Sys.Webforms.PageRequestManagerServerErrorException

I'm working in a web application that work in asp.net with ajax but I have a problem, I'm having the message error:
Sys.Webforms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object
I tried all the options of: http://forums.asp.net/t/1069384.aspx but don't work!
I don`t know what's the problem, because I have two servers and they're one where the application have not problem, and the other with the same configuration and the same application have the problem. So I don't know if the problem is the server configuration, I need a clue, please help me!, I'm 10 days with the problem.
Thanks a lot!
I have the same problom!
One server, two website with one compilation. one is ok and the other throw **Sys.Webforms.PageRequestManagerServerErrorException: Object reference not set to an instance of an objec**t error

Cannot Start IIS on my PC: COM+ System Application: Access is Denied

I'm trying to do some web development. I cannot start IIS (I need to run some Web Services).
As of about a month ago, the "COM+ System Application" service has started failing with this error:
The COM+ System Application service
failed to start due to the following
error: Access is denied.
DCOM also logs an error in the event log:
DCOM got error "Access is denied. "
attempting to start the service
COMSysApp with arguments "" in order
to run the server:
{ECABAFBC-7F19-11D2-978E-0000F8757E2A}
When I start IIS and the WWW service, everthing seems to work until I hit port 80 on my machine at which time the IIS/WWW services both crash unexpectedly:
The World Wide Web Publishing service
terminated unexpectedly. It has done
this 1 time(s).
The following event is placed in the application log as well:
The run-time environment has detected
an inconsistency in its internal
state. This indicates a potential
instability in the process that could
be caused by the custom components
running in the COM+ application, the
components they make use of, or other
factors. Error in
f:\xpsp3\com\com1x\src\comsvcs\package\cpackage.cpp(1184),
hr = 80070005: InitEventCollector
failed
I have searched google until my fingers are numb. I've searched this site to no avail as well.
I have tried:
running the COM+ System Application service as an administrator.
reinstalling SP3 for XP
giving the "SERVICE" account full control to %SYSTEMROOT%\Registration
removing XP Security hotfixes installed about the time it stopped working
I've removed and reinstalled COM+ (it's possible, check google)
Any insight on the COM+ subsystem, it's files and settings or just how it operates would be greatly appreciated.
I need to get this problem resolved so I can get back to work.
Have you seen this link?
http://support.microsoft.com/kb/909444
I'm having the same problem, and it appears it might have fixed it for me - though I did have to reboot afterwards which isn't explicitly in the kb instructions.
(Though it's hard to tell right now if this actually fixed it, because sometimes for me the problem would disappear on its own after a reboot (which doesn't make a lot of sense given the steps in the kb)).
Sorry all.
I forgot to update this when I found the solution... Well, it was self-inflicted. Some months ago, I removed the execute permissions from dllhost.exe. I hadn't been coding asp.net web apps at the time so I didn't notice the problem and couldn't put two and two together very quickly.
I eventually found it by turning on file system failed auditing on my Windows folder hive. I saw a mess of access denied messages related to dllhost.exe and remembered what I'd done.
Thanks for the help.

Resources