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:

image

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

image

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”.

image

image

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.

image

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.

image

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).

image

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.

PHIWUG Presents–Tech Preview

We just did our last technical session for the year 2015!

John Delizo Hosting and a quick demo on Docker and container technologies for deploying applications. And deploying applications to Windows Server 2016 Tech Preview.

Ren Narvaez on Microsoft Infrastructure Datacenter Security Today

WP_20151210_002

Milo Pacamara on PH Emerging threat landscape and why upgrade

WP_20151210_003

Felmar Tanada on Windows Server 2016 Preview: Nano Servers

WP_20151210_009

Thank you for attending this session!

WP_20151210_013

September 2015 MSDN Session at Globe–Event

Thank you PHINUG for the invitation to talk about continuous integration with Visual Studio online and Microsoft Azure.

2

Warren Yu, Microsoft MVP: Application Lifecycle Management

b

Michael Peña, MSP Alumnus currently at Avanade

5

Jerome Punsalan’s lightning intermission number to perk up while eating.

c

Me (John) Taking questions from the audiences.

4

Again thank you and see you on the next PHINUG event!

1

September 2015 MSDN Session at Globe

PHINUG celebrates only tech talks and love for the cloud if you remember the 17th night of September!

The Philippine .NET Users Group (PHINUG), Microsoft Philippines, and Globe Labs presents another installment of MSDN Sessions, a monthly series of weekday after-office hours talks for software development professionals and enthusiasts of Microsoft developer technologies.

The event will be held on will be held on Thursday, September 17, 2015, 6:00 PMto 9:00 PM at Globe Telepark Valero, which could be found at Valero St. (near VA Rufino), Makati City.

Our speakers for the next session will be:

  • John Delizo, MVP for Software Packaging, Deployment, and Servicing, is going to talk about DevOps and Continuous Delivery using Visual Studio and Microsoft Azure, and discuss about how Microsoft Azure and Visual Studio Online helps developers in increasingly automated development, testing and deployment setups.

  • Warren Yu , MVP for Application Lifecycle Management will discuss aboutLeveraging VS ALM tools in a Lean Startup Environment. Warren will discuss how to get those products out in the leanest/meanest way possible.

We also have a lightning talk:

Michael John Pena, MSP Alumnus will discuss about Portable Class Libraries.

Food and drinks will be served at the event. See you there!

 

https://phinug.doorkeeper.jp/events/31422

Containers at Microsoft Big Top Festival

SAM_3654

So me and Edison talked at Microsoft’s Big Top festival in Blue Leaf Macapagal. We shared a slot to talked about the things we are doing in the past and how it is being done in the modern world with Microsoft Azure. Edison talking about open source on Microsoft Azure.

SAM_3703

Certainly the days when we host our PHP and ASP websites with some hosting company or even in the office.

SAM_3705

Dev-Ops were different back then, right now, it’s a one line switch from one container to another container thru PowerShell.

SAM_3709

Switch production systems in seconds not days.

SAM_3712

So there, Full development, Dev-Ops, Open Source, on one platform. Good times!

SAM_3702

 

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.

image

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.

image

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.

image

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.

image

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.

image

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

image

Happy CI-ing WCF Services! Smile