Posts

Migrating database from ASP.NET Identity to ASP.NET Core Identity

Image
As you know ASP.NET Core Identity (table structure) is different from what we had earlier in ASP.NET Identity. Actually the identity system which we have today with .NET Core is very mature and continuously evolved be it ASP.NET Membership, ASP.NET Identity 1, ASP.NET Identity 2 and now ASP.NET Core Identity. Recently I had to migrate few application to ASP.NET Core and similar its identity database. Because the table schema is changed, i had to re-think and create migration script which I would like to share with you today. It is very simple and easy, just three step and I had everything ready: STEP 1 : Change name of existing tables STEP 2 : Create ASP.NET Core Identity tables STEP 3 : Migrate data from old tables (ASP.NET Identity) to new tables (ASP.NET Core Identity) Script:  https://gist.github.com/itorian/c699e8534b392a6c726ec66c48100072 You should also watch my video, where I demoed migration.

Lambda two tables and three tables inner join code samples

In this blog post you will learn inner join using lambda queries. There will be two samples, in first sample you will see how you can join two tables and in second sample you will see how you can extend even further to join three tables and so on. I will sample in-memory data, but the same implementation will work with IQueryable (lazy query) too. Here's the code snippet:- namespace ConsoleApp1 {     class Program     {         static void Main()         {             var table1 = new List<Table1>();             table1.Add( new Table1 { Id = 1, Name = "Name 1" , Address = "Address 1" });             table1.Add( new Table1 { Id = 2, Name = "Name 2" , Address = "Address 2" });  ...

How to move web.config connectionStrings in a separate web.config file ?

In this post you will learn how to create a separate web.config file in ASP.NET or MVC to store development and production versions of connection strings. Step 1. Create a PrivateConn.config file on root with below code < connectionStrings >   < add name = " DataConn1 " connectionString = " Data Source=server;Initial Catalog=database1;Persist Security Info=True;User ID=sa;Password=xxxx;MultipleActiveResultSets=True;App=EntityFramework " providerName = " System.Data.SqlClient " />   < add name = " DataConn2 " connectionString = " Data Source=server;Initial Catalog=database2;Persist Security Info=True;User ID=sa;Password=xxxx;MultipleActiveResultSets=True;App=EntityFramework " providerName = " System.Data.SqlClient " /> </ connectionStrings > Step 2. Open main web.config file (on application root) and then define new config file path, as given below < configuration >   ...

How to move web.config appSettings in a separate web.config file ?

In this post you will learn how to create a separate web.config file in ASP.NET or MVC to store development and production versions of application settings. Step 1. Create a Private.config file on root with below code < appSettings >   < add key = " data1 " value = " value1 " />   < add key = " data2 " value = " value2 " /> </ appSettings > Step 2. Open main web.config file (on application root) and then define file path with appSettings start tag, as given below < configuration >   ....other codes   < appSettings file = " PrivateSettings.config " >     < add key = " webpages:Version " value = " 3.0.0.0 " />     < add key = " webpages:Enabled " value = " false " />     < add key = " ClientValidationEnabled " value = " true " />     < add key = " UnobtrusiveJavaScriptEnabled ...

Can test automation replace manual testing?

Short and simple answer, NO. It cannot. Let's talk why, we cannot replace manual testing. Consider, a form screen showing a extra textbox or a wrong color in any control or a wrong modal, but the entire functionality works fine otherwise. Such things would easily be missed if you have a 100% automated test cases with 100% test coverage, because automated testing looks more at what is expected and less at what is not expected. We see a ton of software's around for test and its automation, and they are divided into different categories: 1. Test Management Tools - Azure DevOps, PractiTest, TET (Test Environment Toolkit), TETware etc 2. Functional Testing Tools - Selenium, Soapui etc 3. Load Testing Tools - Azure DevOps, Jmeter, FunkLoad, ANTS etc Any tool you select has list of features and they power up software testers or testing. Manual testing will stay and advocate manual testers to develop skills like scripting which can make them more efficient and do a better job. Both ...

Reading NS records in C# using ARSoft packages

In this post you will learn about reading NS records in C# using ARSoft packages. This package is handy to read domain NS records. Here's a sample code which will help: using System; using System.Linq; using ARSoft.Tools.Net; using ARSoft.Tools.Net.Dns; namespace ConsoleApp14 {     class Program     {         static void Main(string[] args)         {             var dnsMessage = DnsClient.Default.Resolve(DomainName.Parse("learninhindi.com"), RecordType.Ns);             var nsrecords = dnsMessage.AnswerRecords.OfType<NsRecord>();             foreach (var record in nsrecords)             {             ...

Customizing "Edit Top 200 Rows" in SQL Server Management Studio

It is a very common requirement that, sometimes we want to change the edit top 200 rows query. This is very much possible and easy in SQL Server Management Studio. Right click on table and select "Edit Top 200 Rows" Press "Ctrl + 3" on rows in edit mode window Now you can see the query which returned 200 rows allowing you to edit On this query window, right click to execute the query on window itself And voila, you have records based on your query to edit those on window :) Hope this helps.

Create virtual machine using PowerShell command

Just run this PowerShell script to create virtual machine, you can change setting in order to have other operating system and pricing. Hope this helps.

Free SSL Certificate for your website - from CloudFlare

Image
In this video post you will learn about free SSL certificate and its installation. This free SSL certificate is from CloudFlare but due to lack of installation guidelines and step by step we as a developer ignores this. Using CloudFlare SSL is a great advantage because you get other service for free too. Off-course, with paid plans you will get all the gems. Remember this never affects your SEO ranks. Now, let's begin talking about this free SSL certificate. CloudFlare SSL sits between your user and your hosting server. So any potential attack is taken care by CloudFlare before they reach your server. So your user will see SSL certificate till their request reaches CloudFlare server. If you already have a website running without SSL and you want to get this, then i would recommend to take a screenshot of your domain NS, CNAME, A, AAAA, MX records before you try this. If you don't want any downtime, off-course, then steps would be like: whatever settings you have on your ...

Migrating Azure VMs on VNet from Azure Service Management (Classic or ASM) to Azure Resource Manager (Resource Manager or ARM)

In this post you will find code snippet to migrate your classic Azure VMs that is part of virtual networks. That is, you will learn Migrating Azure VMs on VNet from Azure Service Management (Classic or ASM) to Azure Resource Manager (Resource Manager or ARM). Without too much discussion, let's start step by step. You need to have PowerShell installed. In the process of migration you first need to sign in your subscription using modern way that is ARM to prepare migration and then sign in your same subscription using classic approach that is ASM to perform migration and commit. Step 1. Let's login ARM Login-AzureRmAccount Step 2. Store subscription id into a variable $SubID = "1345e4-4561-1bd7-55c1-e3848012qw4r" Step 3. Select subscription using above variable Select-AzureRmSubscription -SubscriptionID $SubID Step 4. Now, let's prepare the migration on ARM, this operation may take few minutes. Register-AzureRmResourceProvider -ProviderNamespa...

Slug URL in MVC

Creating a human friendly URL is one of the important goal in content management system. Recently one developer asked me this question. Like he always sees 'id' in URL in MVC application which is not human friendly. He mentioned stack-overflow example when explaining issue to me, so let’s discuss about this. Open stack-overflow page https://stackoverflow.com/questions/40956081 you will be redirected to https://stackoverflow.com/questions/40956081/runtime-exception-thrown-when-stdvector-destructing Notice the last part in the query, this is nothing but a slug that is being added in URL all the time. Technically both URL maps to same resource. And in URL number '40956081' is unique identifier. I hope you know Stack-Overflow is also build using ASP.NET MVC. Let's build similar slug and similar behavior in your MVC application. First you need to configure your route as give below: public static void RegisterRoutes(RouteCollection route...

Azure Media Service Encoding with custom presets

Image
In this post you will learn how to use custom preset for Azure Media Service Encoding. But before that let's look at a case study or issue which I faced. When I uploaded a 55.5 MB mp4 file and encoded with "H264AdaptiveBitrateMP4Set720p" encoder preset, I received following output files: Look into green rectangular highlighted video files in the image, this looks good according to input file size. But if you look at red rectangular highlighted video files, these are *improved* files for adaptive streaming, which looks useless if you compare with my example "a dark line on my face in video can't be removed by system automatically...make sense". Here I'm trying to understand Azure Media Services encoding permutations but increasing file size 2-3 times larger than input file is never a acceptable deal. Why I should pay more for bandwidth and storage on these large files, how I convince my clients? On this issue I thought to under...

Popular posts from this blog

Customize User's Profile in ASP.NET Identity System

Migrating database from ASP.NET Identity to ASP.NET Core Identity