Truemag

  • Home
  • Angular JS
  • C Sharp
  • DevOps




February 2018 6

Using Entity Framework 6 With AspNetCore2

In Today’s article we are going to discuss about the using entity framework 6 with aspnetcore2 application.

Entity Framework 6

EF6 stands for entity framework 6 and its a data access technology. The first framework of EF6 or Entity Framework 6 was released in 2008.

There are two ways in which we can use entity framework 6 in our application.
Code First
Database First

AspNetCore2

AspNetCore2 is a new flagship from Microsoft for the web development purpose. AspNetCore is a lighweight application.
[insertAdsense] Below are the requirements for using Entity Framework 6 with AspNetCore2

Let’s start by adding a class library in the application and name it as AspNetCore2WithEF6.Data

After adding the class library use the below command in the package manager console to install Entity framework 6:

npm install EntityFramework

After Installing the entity framework 6 create three class files with name StudentDbContext.cs, StudentDbContextFactory.cs,Student.cs and MasterDataInitializer.cs. Add the following code in the files:

MasterDataInitializer.cs
StudentDbContext.cs
Student.cs
StudentDbContextFactory.cs

After adding the above code run the below mentioned commands in package manager console:

enable-migrations
add-package Initial
Update Database

After completing all the above steps, add a new AspDotNetCore2 application in your solution.

Make three code changes in the aspnetcore2 files.

 

 

 

How to use Http Post in Angular 4

angular js

How to generate a component using Angular Cli

angular js

Run the below command to confirm that angular cli is installed on your system:

ng --version

Once you run the above command you get a screen similar to the below screen:

Once you are sure that angular Cli is installed on your machine, then you can run the below command to generate a component:

ng generate Components or
ng g c

Below are some of the parameters that can be used with angular cli:

--app
--change-detection
--flat
--export
--inline-style
--inline-template
--module
--prefix
--skip-import
--spec
--view-encapsulation

Business Rule to create a TFS bug from Service Now

Servicenow is one of the most popular ITSM tool for Incident Management in the Information Technology industry. ITSM stands for IT Service Management. The responsibility of the ITSM tools are to provide support to the IT employees, so that they can work in an orderly manner with less chances of any issues coming in the work   Service now is used for the below types of management:

Problem
Incident
Change Management

Problem:

A problem in servicenow is defined as a occurrence of some incidents in the IT industry. The problem makes sure that does not occur again in the system.

Incident :

An incident is an unplanned interruption to a service or the failure of a component of a service that hasn’t yet impacted the service . The incident has a direct relationship with the problem. Some examples of incident are earthquake, Tsunami etc.

Change Request:

Change Request is created when you want to get some new hardware or you want some change in the existing system. One example of change request is to ask for upgrading RAM of one computer.

TFS or Team Foundation server is version management tool which has exposed apis which can be used for creating bugs from any programming language.

Business now has got the capability to run the java script code, which can further be used for writing any login when any of the insert, update or delete operations occur on the tables for incident, problem and change management.

Below is a screen shot for business rules:

How to create a bug using ServiceNow in TFS?

(function executeRule(current, previous /*null when async*/) {
    try{	
	var tfspriority =1;
	if(current.priority.toString()==4 || current.priority.toString()==5)
	{
		tfspriority=4;
	}
	else{
		tfspriority = current.priority;
	}
			
var requestBody = [
     { "op": "add", "path": "/fields/System.Title", "value":  current.short_description.toString() },
     { "op": "add", "path": "/fields/Microsoft.VSTS.TCM.ReproSteps", "value":  current.description.toString() },
      { "op": "add", "path": "/fields/Microsoft.VSTS.Common.Priority", "value": tfspriority }	
	];	
	
var dataObj = JSON.stringify(requestBody);
var client=new sn_ws.RESTMessageV2();
client.setRequestHeader('Access-Control-Allow-Methods', 'POST, GET, PATCH, OPTIONS');
client.setRequestHeader('Accept','application/json');
client.setRequestHeader('Content-Type','application/json-patch+json');
var token = 'Om94bXZncDV6NnNxaaaaWgzY2QyNDZ2Y3llemQyY2szMnppYWxxM200Z2NidDZxMjd0MmU3dHE=';
client.setEndpoint("https://instance.visualstudio.com/MyFirstProject/_apis/wit/workitems/$Bug?api-version=2.2");
client.setHttpMethod("PATCH");
client.setRequestHeader('Authorization', 'Basic ' + token);
client.onreadystatechange = function() { 
	if(this.readyState == this.DONE) {
		gs.addInfoMessage("Bug createdin Tfs");
		gs.info("Bug createdin Tfs");
		}
	};
	client.setRequestBody(dataObj);
	client.executeAsync();		
	}
	catch(ex) {
		var message = ex.getMessage();
		gs.error(message);
	}
})(current, previous);

For more details on servicenow business rules, you can view the following url: https://docs.servicenow.com/bundle/jakarta-application-development/page/script/business-rules/concept/c_BusinessRules.html

If we are able to create a bug in TFS at the same time when some problem has happened in the servicenow, then it becomes easy for the different teams to remain in sync with all the tasks at hand.

 

How to start and Stop a Com+ application using C Sharp?

chsarp-logo

How to start and Stop a Com+ application using C Sharp?

Remember to add the Enterprise Services in your references.

using COMAdmin;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{  

    class Program
    {
        static COMAdminCatalogCollection objCollection;
        static COMAdminCatalog objAdmin;
        static COMAdminCatalogObject objRoot;

        internal static COMAdminCatalogCollection GetCollection()
        {
            //COMAdminCatalogCollection objCollection = new COMAdminCatalogCollection();
            try
            {
                objAdmin = new COMAdmin.COMAdminCatalog();
               // objRoot = objAdmin.Connect("192.168.1.150");

                objCollection =
                    (COMAdmin.COMAdminCatalogCollection)
                     objAdmin.GetCollection("Applications");
            }
            catch (Exception ex)
            {

                Console.WriteLine(ex.Message);
            }
            return objCollection;
        }


        static void Main(string[] args)
        {     
            var status = StartCOMApplication();
        }


        public static bool ShutDownCOMApplication()
        {
            bool ShuttingDown = false;
            try
            {
                objCollection = GetCollection();
                objAdmin.ShutdownApplication("testapp");                
                ShuttingDown = true;
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            return ShuttingDown;
        }

        public static bool StartCOMApplication()
        {
            bool Startup = false;
            try
            {
                objCollection = GetCollection();   
                objAdmin.StartApplication("testapp");
                Startup = true;
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.Message);
             }
            return Startup;
        }
    }
}

How to upgrade from Angular 4 to Angular 5 in Visual Studio 2017

angular js

Asp.Net Core2 has come with the support of the Angular applications. By default, if we create an Angular application in Visual Studio 2017, then it comes with Angular 4.

Here I will show you how we can update our angular application from Angular 4 to Angular 5. Below are the steps for the same:

Create an Angular application in Visual Studio 2017.

If there is any folder with the name of node_modules then delete the folder from root directory of the project.

Open the command prompt as an administrator

Step 1:

npm cache clear –-force

Step 2:

npm install -g npm-check-updates

Step 3:

 ncu -u

Step 4:

npm install

If all the steps ran successfully then, we have successfully upgraded from Angular 4 to Angular 5 in Asp.Net Core 2 Application in Visual Studio 2017.

 

Related Links:

How to add Sticky footer in Materialize design?

Sign up for our newsletter to receive the latest news and event postings.

Recent Posts
  • Case Statement in Azure DevOps
  • How to solve file not found error in Linux?
  • How to delete local branch in git?
  • What is the git command to move branch pointer to different commit without checkout ?
  • What command tracks the revisions in git ?
Recent Comments
  • How to change directory in git bash? - Prashant's Blog on How to delete local branch in git?
  • eebest8 on How to use Http Post in Angular 4

  • Case Statement in Azure DevOps
  • How to solve file not found error in Linux?
  • How to delete local branch in git?
  • What is the git command to move branch pointer to different commit without checkout ?
  • What command tracks the revisions in git ?
  • Home
  • Angular JS
  • C Sharp
  • DevOps
  • June 2020
  • April 2020
  • February 2020
  • July 2019
  • June 2019
  • May 2019
  • January 2019
  • November 2018
  • October 2018
  • September 2018
  • July 2018
  • March 2018
  • February 2018
2018 © Prashant's Blog