How to apply license on SCOM 2016(fwlink 74446)

Today I had a chance to revisit my SCOM Lab. But after booting everything, I noticed that even if all services are running including SQL and SCOM, the Ops Manager console throws an error on connecting.

TL;DR; My trial license is expired. Use Powershell to apply license:

  • Import-Module OperationsManager
  • Set-SCOMLicense –ProductId “<YOUR PRODUCT KEY>”
  • Restart-Service OMSSDK
  • New-SCOMManagementGroupConnection
  • Get-SCOMManagementGroup | Format-List –Property SkuForProduct, SkuForLicense, Version, Name, TimeOfExpiration

Long story, so will I reinstall today? So normal troubleshooting after seeing the error, restarting the services including SQL Server and nope, no joy there.

Going back to the console, thankfully there is a stack trace there. So lets read thru the errors, mostly access denied exception but there was the ex.message.toString there. So we have hopes here.

It seems that there was an access denied exception but the inner message is saying “You have exceeded the evaluation period of this product. Please upgrade to the retail version to continue using the product” Aha! I followed the link and it seems that it only redirects to a generic product page. Still no joy.

image

There are a few TechNet and Support articles out there, but there’s one problem. License IS expired already.

https://support.microsoft.com/en-ph/help/2699998/how-to-add-a-product-key-to-the-eval-version-of-system-center-2012-ope

https://technet.microsoft.com/en-us/library/hh966734(v=sc.12).aspx

Problem is we cant connect to the management group, because, yes we have an exception. Yikes.

image

I think the article is a little off, since applying SCOM licenses are thru registry access so it shouldn’t require any connection.

So first, run PowerShell as an administrator on the server where SCOM is installed.

Apply the license key that you have for retail. (See TLDR section for Copy-Paste PS> commands)

Also remember also to restart the System Center Data Access Service after applying the license. Included in TLDR.

image

Try out the new connection and try and poke the management group and get the license details.

Then try and connect using the Console. Yes its working, but my apps are not.

image

So there ya go, and I’m back to my DevOps management group. I’m trying out the new MP for .NET APM with Application Insights. This is going to be fun. Well after we fix DB01. Should blog about it later.

Cool DevLife Hack on VS2015–Paste Special!

So I saw this post on MSDN Philippines and Philippine .NET Users Group Facebook feed about “cool #DevLifeHacks” that nobody else knows about. So may as well contribute to this fun.

image

And my entry! Visual Studio 2015 Paste Special! Oh Yea!

image

Simply copy any XML or JSON and turn it into instant C# Classes!

image

I am not kidding. From Weather.gov Json result, instant C# classes, complete with getters and setters from primitive types to objects.

image

How’s that for a “cool #DevLifeHack”?

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.

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