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.

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

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?!”

image

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.

image

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

image

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: http://support.microsoft.com/kb/287932 

image

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

image

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>

or

taskkill –pid 7372 as seen in my example.

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

image

You should be able to log-in in SSMS 🙂

image

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 🙂

image

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 VisualStudio.com (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:

http://www.windowsazure.com/en-us/support/service-dashboard/

image

I searched the net and so far here’s from the TFS Service blog on MSDN: http://blogs.msdn.com/b/tfservice/archive/2013/02/22/service-interruption-2-22-2013-update.aspx

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.