Surendra Sharma

Surendra Sharma

Search This Blog

Showing posts with label Visual Studio. Show all posts
Showing posts with label Visual Studio. Show all posts

Saturday, October 1, 2016

How to use Visual Studio 2013 for Sitecore 8.2




I received Sitecore 8.2 EXE file and was trying my hand with new features of Sitecore 8.2. I created web project in Visual Studio 2013 with .NET framework 4.5. I copied Sitecore.Kernel.dll and Sitecore.Client.dll from Sitecore 8.2 bin folder and included their reference in my web project.

I write below test code and at design time it looks fine to me. 

Design Time Code
Design Time Code


But when tried to compile it, VS started to giving me error “The type or namespace name 'Sitecore' could not be found (are you missing a using directive or an assembly reference?)” as

Compile Time Errors
Compile Time Errors


I was trying to figure it out what is the problem and how to fix it?

Problem:

I check .NET framework version for my VS project and it was set as 4.5 as

Target Framework 4.5
Target Framework 4.5

Then I check the version of Sitecore 8.2 installed instance in its web.config file which showing it as 4.5.2 as


Sitecore Instance Version
Sitecore Instance Version


So I was referring higher version of DLL in lower version of .NET framework Visual Studio project which obviously not allowed by any framework.

How to fix it?

We have to create our web project in .net framework 4.5.2 or higher version.

From where to download?

  • Right click web project in Visual Studio
  • Select “Properties
  • Select “Installed other frameworks…” from target framework dropdown list as
 
Install Other frameworks
Install Other frameworks
 
  • This action redirects you to framework download page.
  • Download appropriate .NET framework according to your Visual Studio version. I select Visual Studio 2013 and downloaded Developer framework pack 4.5.2 and 4.6.2 as
 
Targeting .NET Platforms
Targeting .NET Platforms


Post Download steps:

  • I installed first framework 4.5.2 and then framework 4.6.2.
  • I change my Visual Studio project version from 4.5 to 4.5.2.

Dot net framework 4.5.2
Dot net framework 4.5.2
 
  • Ignore Visual studio warning on framework version change. 
  • This action include web.config file in our web project. 
  • Note:- Make sure to delete this new web.config file otherwise on build this config file replace our web.config file in publish folder which crash your Sitecore instance.
  • Build the solution.
 
OMG my project is compile successfully now and I am able to get required result in Sitecore 8.2 :)

Conclusion:

If you have Visual Studio 2013 and want to work with Sitecore 8.2, make sure you have created your web project in .NET framework 4.5.2 or higher.
 
This is another Sitecore learning lesson for me. Please leave your comments or share this learning lesson if it’s useful for you.

Sunday, August 28, 2016

Content migration guide for Sitecore


Content migration is itself a project within a project and luckily I was extensively involved on different projects where content migration is one of the most important story of the project.

In one of the Sitecore project, I developed lots of scripts to migrate over 500,000 records from different sources to Sitecore.

During these migration, I come across with different situations and found some most suitable way to deal with.

I tried to cover all such technics in this guide. Below are the key topics that I want to emphasized
  • Introduction
  • Questions for client
  • Data Mapping
  • Data Representation and Mapping
  • Source of Data
  • Data Migration Map
  • Why SQL Server
  • Guidelines for content migration resources and team
  • Images and Media
  • SITECORE ITEMS
  • Sitecore Fields
  • Migration Code
  • Log Files
  • Code Technique
  • Testing

I tried my best to include all the scenarios that are associated with content migration.

You can read and download this white paper from here:




Please leave your comments or share this guide if it’s useful for you.

Saturday, February 27, 2016

How to do database documentation freely



I am working on project where client asked for the documentation.

Developers hate documentation, especially when they have to create it :)

It’s fine if the documentation is about project, but what if client asked about database documentation?

My mind started to think, is there any way to create this documentation automatically or with least efforts?

I found three ways which are great to create database documentation.

1.    Database Diagrams

It provides database schema with relationships and tables-columns details in SQL Server itself as shown below


2.    DB>doc
It’s a free command line tool which can be download from https://sqldbdoc.codeplex.com/ .

It provides option to generate output report in HTML, wikiplex or XML format.

Its syntax is sqldbdoc connection fileName [/y] [/f:value] [/debug]

Parameter details are
·         connection -  connection string of database
·         filename - output file name
·         [/y] - overwrite output file
·         [/f:value] - output format: html, wikiplex, xml (autodetected when omitted)
·         [/debug] - debug mode (show detailed error messages)

How to use this tool?
1.    Download sqldbdoc.exe from https://sqldbdoc.codeplex.com/ and keep it in some folder, for example, D:\Share

2.    Type cmd in RUN window which open command prompt 

3.    Change directory to D:\Share and type below command with SQL server connection string and output file name
D:\Share>sqldbdoc.exe "Data Source=.\SqlExpress;user id=sa;password=test@123;DATABASE= Sitecore_WebForms" Report.htm
4.       You should get below output which indicate successful report generation
Altairis DB>doc version 1.0.0.0
Copyright (c) Altairis, 2011 | www.altairis.cz | SqlDbDoc.codeplex.com
Autodetecting output format...
Output format: html
5.    Open “Report.htm” from current directory i.e. D:\Share. You should get below nicely formatted report as

 
  
1.    SQL Server Compact & SQLite Toolbox

You can download and install this free Visual Studio addon SqlCeToolbox.4.5.0.1.vsix from https://visualstudiogallery.msdn.microsoft.com/0e313dfd-be80-4afb-b5e9-6e74d369f7a1/

How to use it?

·         Open Visual Studio and click on Tools -> SQL Server Compact/SQLite Toolbox menu item as


·         Connect to any SQL server database which need to be documented.
Once connected, you can create database graph of the tables by selecting option “Create SQL Server Database Graph (DGML)” as

 

·         This tool generate DGML file which show all selected tables with their columns and relationships. You can save this screen as image by clicking on Copy Image option as shown in the same screen.

 

·         You can also save the SQL connection database as SQL Server Compact file format which save this database in .sdf file format.
In this format you can do the database documentation in HTML format by selecting below option


You should get below HTML report


This HTML report is same as DB>Doc tool report. Internally this Visual studio add on uses DB>Doc utility.

My suggestion is that combine SQL Designer schema image with this HTML report to create better database documentation.

Also I found that command line utility DB>Doc is more easy to use for developers.

I hope these steps help you to do the boring documentation automatically and save your time.

Please leave your comments or share these technics if it’s useful for you.