Error CS1061 'ApplicationDbContext' does not contain a definition for 'ApplicationUsers' (Fixed)

Visual Studio ASP.NET MVC controller with views and EF template creates db.ApplicationUsers instead of just db.Users. 

Workaround summary:

1. Rename ApplicationUsers to Users

2. Delete the Controller and View

3. Close and Re-open VS and Project. Rebuild.

4. Recreate the Controller!


So its in the morning, you said lets scaffold! And you got this error:


This happens when you reference a foreign key your “ApplicationUsers” that is used in the IdentityDbContext that inherits IdentityUser.


And then when you add a new controller with views using EF the scaffold will generate the ApplicationUsers but its DbSet or property of the object will not be available. 

One workaround is to rename your ApplicationUsers to only “Users”.



Now this is important, delete the controller and its views folder after renaming. Then you need to close visual studio. 

Open the project once more and rebuild your solution.

You should now be able to scaffold the controller.


Happy Scaffoldings!

Chain Commands in Package Manager Console and PowerShell

So its late, I am in a hurry and am very hungry. I needed this to be quick.


You can actually “Chain” or have sequential commands in one line using PowerShell. To do this use a semicolon “;” in each statement or command.

What it does is execute each statement or command then brings back the cursor to you after the last command was executed.

Since Package Manager Console uses PowerShell. In fact, a simple get-command will display a long list of commands and modules (As I demonstrate… a long list, not a good idea without any filters on get-command on a development computer).


So using PowerShell’s Sub expressions, you can also chain your commands like enabling the migration and then adding an initial migration then finally update the database on one command inside package manager console.

It’s the little things.

Unit Testing and CI of WCF Services

This is one of the reasons why I use WCF for all of my API projects.

There are a lot of ways to test a WCF Service Application, that we are using. I would to do a disclaimer that this may be appropriate for our use but may not for your scenarios. Moreover, what we are testing are the “functionality” of the methods exposed by the service and on tests we bypass most of WCF’s infrastructure.

The first thing you have to make sure is that the service is testable. This a default WCF implementation if you create it directly from the Visual Studio project template.


You wanted to create the service as an abstract class and implement it as a partial class, we do this so that we split most of our logic into multiple files and for this context, which is a unit test discussion, to not to be confused about the references. As you can see, there are 353 references to the partial class and these are all from unit tests.  From this point forward, the red class is our partial class.


Then you add the Service Implementation project as reference to the unit test projects. Make sure to add your Message and Data Contracts as well.


When you create the unit tests, you call the partial classes (in red) and then use it as it was just another class. Test it, use data source if you wish.


Note that this bypasses all WCF infrastructure and is only used for tests like its functionality and removing the networking component. You will also notice that you are not spawning any  IIS or host the WCF service to run test against it.


This now can be checked-in in TFS and do automated tests in your CI.


Happy CI-ing WCF Services! Smile

Visual Studio 2013 hangs on debug (Fixed)

Quick solution: Uncheck show all files.

I was coding for my personal project and after a few hours of debugging, VS seems to hang. I am pretty sure its not the hardware, so lets get that out of the way.

The solution contains a number of projects and folders. So to test, I created an empty solution, added the project and nada. I might be doing something wrong. Maybe VS settings? Symbols? But I already make sure that my build of VS follows my guide so its not it.

After tinkering around, setting settings gave up. So I will debug for one solution for now, its just a view change and do a build after check-in. I noticed that the icon ‘do not show all files’ is ticked, saying “who is adding files again thru solutions explorer?!”


Un-tick it, debug and hey! It works! Gotta try this now on the main solution.

Windows could not start SQL Server Error Code 100048

So SQL Server on my dev machine is not running. I think this machine did an update today and when I came back it was restarted.I don’t use SQL Server on my laptop not unless I am doing development outside of the office so my SQL Server Service is set to start manually.

Tried starting the SQL Server (MSSQLSERVER) service  manually using services.msc but there are errors: Windows could not start the SQL Server on Local Computer. For more information, review the System Event Log. If this is a non-Microsoft service, contact the service vendor, and refer to service-specific error code 100048.


So it says check event viewer (eventvwr) for the details:


Yeah, there are some errors! Checked one by one saying check the previous error so I did. Says TCP port 1433 is already in use. We all know that port 1433 is used by SQL Server. See: 


Lets terminate that process so that using 1433. Lets check using netstat.

Open a command prompt using Administrator (Run as Administrator) and type: netstat –a –n –o | findstr 1433


Take note of the process ID. It is the number at the right most column. Take note of it and terminate it. Use:

taskkill –pid <ID>


taskkill –pid 7372 as seen in my example.

Now after terminating / killing the process, switch back to the Services console and start SQL Server.


You should be able to log-in in SSMS 🙂


Okay now, back to work!

February 2014 MSDN Session

So Me and my team headed out to attend PHINUG’s MSDN Session last February 27, 2014, also to meet other MVP’s and ofcourse friends. Its just so happen they wanted to start early and MVP Jon Limjap volunteered (more like surprised) me to do the first session.

So I took the opportunity to talk about how PHIWUG is now using Visual Studio TFS online and Windows Azure to host its new Forum.

This is MVP Allan Mangune talking about data access, with Stored Procs, Entity Framework and In-line SQL that started as a Facebook post 🙂

Thank you PHINUG for inviting and the surprise / impromptu talk! Lets do this again.. 

VISUALSTUDIO.COM : The server encountered an unknown failure: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel

Maybe this is telling me to go do a better Saturday than continue coding for our new product 🙂


I tried to check-in some changes that I made in our solutions and I got this error: The server encountered an unknown failure: The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel. We are hosted to (the former TFS Service). If you also have this error, it means that there is a problem with the TFS Service or in Azure. Check out this link for their Service Dashboard:


I searched the net and so far here’s from the TFS Service blog on MSDN:

So I guess, I would not be doing some check-in’s for a while. It’s a good Saturday and its weekend. I should not be working now lol. Bye for now.

How Team Foundation Service enabled, efficient and saved a team of Ninjas a number of times!

I have not blogged for a few weeks now because of my left and right projects – running around to places and I just had to do a blogpost today to highlight one of the best tool in my teams arsenal: the TFS Service (


Disclaimer: Today it is called TFS Preview, Preview, It means its not on its not yet a full product like a beta. So if you are going to try this out, even on a live project like me, please make sure you have a fallback, back-ups and alternatives. I on the other hand, saw the potential early on and I weigh the risks involved in contrast with the benefits that it would give my team – thus I decided to go ahead. But that’s just me.

So what’s Team Foundation ? TFS is a collaboration platform for application development thru its life cycle. It is used to be a stand-alone product that needs a Windows Server Platform and a list of hardware and software requirements  for you to take advantage of its capabilities. What Capabilities? If you are a developer or a development project manager, you will love TFS. TFS gives you the ability to manage your team development process. In a nutshell id like to give a simple run-thru. A scenario when you already have the architecture of the application to be built and it just needs to be assigned to each developer.

  1. Assign a work item to a developer and track its progress.

  2. Developer writes code based on those work items. Submits the source codes then if necessary closes a work item when he or she is already finished, informing the project manager real time.

  3. Other developers writes code in parallel, with the ability to merge their work.

  4. Versioning of source codes. Each changes are saved in the server for later review or the eventual rollback just in case.

  5. Automatically translate these source codes to usable software.

  6. Test the software an file a “bug” task to a developer to be fixed.

    That 5 above, you can summarize that as in Work, Source Control and Build.

The above screen is the Home dashboard for the TFS Preview and it still reminds me back in the days where I had worked with TFS since the 2005 and that I have always wanted is a secure out-of-office access that enables me to assign work items, check bugs and also contribute on the source codes deliverables. Especially nowadays that I am running around all over places (or working from home and outside :p ).

In the advent of Cloud and the Microsoft Azure Services, why not put TFS in there! Azure is basically a Microsoft Cloud service and platform. These are always-on powerful servers, hosted in the cloud.


For more info about Azure, check this out

So instead of putting TFS instances in premise servers, we can now use TFS as a pay-per-use service hosted on Windows Azure. Yes, no server set-up needed.

And how did this new service made our lives basically easier and our team productive.

One. Collaboration. It gave us a system that enables us to work on one source. We felt the importance of collaboration thru one source when somebody cannot use TFS at the moment. That each and everytime he  /she will give a new source codes, I had to manually merge it and messes up everything. When he joined TFS, we already overcame the manual merge nuisance at last.

Two. We are all over places (ehem our homes, some coffee shop or anywhere where we can sit around and code). Gives us mobility. We can work anywhere as long as we have internet connection (even just for synching) – its like using your email client that you can compose your email replies on the go and just sync when there is an internet connection available.

Three. Service Resiliency. Lets just be realistic, powers go out, internet connections go bad. Server hardware crashes. We have seen a lot of these problems in our sprints and we never had to worry about the main source code and work item repository (TFS).



Four. Branching, Merging, Versioning.

Source code versioning is very important. It gives you a chance to go back in time to look for changes. Each change is group, thus called “Change Sets”. Each change set has a unique number associated with it and all other information like who submitted the change set, when was it done and ofcourse the ability to manage file conflicts – called merging. Sometimes two developer works on a single file, its like two person working on a single excel file or a word document, then merge their work later.



Branching is also a way to version the source code, having copies of the entire source code. Commonly used for back-ups, rollbacks and if different teams are using the code, like one branch is for Production Issues another branch is for Bug fixing then the build administrator merges the changes between the two branch. I

Let me share this scenario that has just happened last last week. Somebody deleted some code on the branch. He accidentally dragged a folder away and was deleted after he “submitted” his change set to the repository. “If we did not have TFS and I hadn’t branched last night, we are doomed”. But for now, I can sing:

“Branching, Merging, Com en-Versioning. Say it ain’t so, I will not go. Turn the lights off, carry me home. Na, na, na, na. Na, na, na, na, na, na, na, na, na, na, na”


Five. Continuous integration or CI. This is automatically “building” or “compiling” the current version of the source code and deploying it to the target system for testing. If the source code is not properly written, it would yield a “Compile or Build error” and cannot be deployed. When there is a compile error, we can file it as a bug and the developers can fix that as a part of their list of work. For it to automatically do CI, TFS needs to listen for a trigger, maybe a new source code submission, scheduled or a manually triggered event. Combination of these in a nutshell are called build definitions. You can even trigger a CI on the web 🙂




I have configured a lot of CI but configuring it on an SUR40 made it to the top of the coolest CI build that I did. Maybe I’ll blog about it later but for now I gotta get back there so TFS Guys at Microsoft, in behalf of our Ninja team thank you tfsservice!