Generate POCO for Database Tables Using T4 Template

Posted on Mon 12 May 2014 in Developer • Tagged with poco, t4, dotNET, C#Leave a comment

If you are using Micro-ORM which doesn’t have fancy UI that generate your data model for you, or you want a free tool to generate POCO classes for you, I’ve got a solution for you. Personally I prefer using T4 template that PetaPoco provides, so let’s see how you can use it.

Let’s Start:

First, install/add PetaPoco to your project using Nuget:

1.  Open **Package Manager Console** and type `install-package petapoco`
2.  Wait until package downloaded and installed to your project.

packagemanager

solutionafterinstall

Second, modify T4 template to generate POCO classes for you:

  1. Open Database.tt file and modify Settings part.
  2. In ConnectionStringName write your database connection string name which located in app.config or web.config.
  3. In Namespace write the namespace for generated Poco classes.
  4. In RepoName write Repository name, this is optional and recommended if you’ll use PetaPoco.
  5. In ClassPerfex write required class name prefix, this is optional.
  6. In ClassSuffix write required class name suffix, this is optional.
  7. Save the file.

settings

Third, congratulation your POCO classes and Repo generated under Database.tt –> Database.cs.

pocos

Notes:

  • Make sure you set providerName in ConnectString or T4 template will not work.
  • If you faced C# issue during …
Continue reading

Book Review: Windows PowerShell 4.0 for .NET Developers

Posted on Wed 30 April 2014 in Review • Tagged with book, bookreview, dotNet, powershellLeave a comment

dotNET_Developers

My academic colleague Sherif Talaat released his second book Windows PowerShell 4.0 for .NET Developers which is filling the gap between .NET Developers and Administration tool like Windows PowerShell, before reading this book I was having small information about PowerShell and I didn’t know it’ll help me in my development tasks. Target audiences of this book are .NET Developers.

Chapter 1: Getting Started with Windows PowerShell

It’s an introduction chapter with very basic information about PowerShell and the scripting environments.

Chapter 2: Unleashing Your Development Skills with PowerShell

From this chapter things start to get real and you’ll find script to do some job like Create .NET Object, parse and query XML files, create modules, etc..

Chapter 3: PowerShell for Your Daily Administration Tasks

Where things getting more excitement, in this chapter you will learn how to use execute PowerShell cmdlets remotely on other machine, execute your script as workflow, use PowerShell with SQL SERVER and IIS (Internet Information Services), and last but not least manage local users and groups with PowerShell.

Chapter 4: PowerShell and Web Technologies

In this chapter you’ll see that PowerShell can deal with Web Services SOAP or REST …

Continue reading

.NET Developer Comfort Zone

Posted on Mon 17 March 2014 in developer • Tagged with developer, development, dotNetLeave a comment

red-pill-or-blue-pill

I’m a .NET developer and to be specific I’m a web developer who use .NET framework and .NET stack to create web application (Web App), and nowadays I’m learning ASP.NET MVC to move from WebForms world to MVC world, but in future I’m planning to get out of my comfort zone again and get out of .NET world and try the open source software (OSS) world, I’ve attended many sessions for GDG Kuwait which is Google Developers Group located in Kuwait and the only developer group in here with .NET/C# experience and it’s full of enthusiasm developers.

When I will take this leap/paradigm shift I will take it for real, let me explain what I mean by that. What I’m planning is learning Ruby on Rails, maybe you want to learn Django or Node.js but when you will, please don’t try to stick to Microsoft world, don’t be afraid to get out of your comfort zone, please don’t use Node.js tools for Visual Studio, or Python tools for Visual Studio, or Ruby In Steel Developer these Frameworks works great with Linux operating systems so learn …

Continue reading

Storing password in plain text, you’re doing it wrong

Posted on Wed 06 March 2013 in ASP.NET • Tagged with security, dotNet, CsharpLeave a comment

Hacking for password

If you’re software developer then there is big chance you’ll implement user login feature, and you must store the username and password in your system. Most of developers stored these precious information in database as plain text, yes we did include myself I was doing it wrong, and if you’re doing it please stop and read this article to know how to do it right and being awesome.

Username, Password, or Pin codes these are precious information, and if hacker or even internal employee stole the database he can do whatever he wants with your users information. So How to keep these information safe? The answer is hashing it.

Why I was not doing that? I was lazy and every time I googled/binged/searched about this, I found many complex How-To articles, but last week I finally found something simple and it’s the reason I’m writing this article.

What is hashing?

Hashing is encoding string "message” to hash value and you can’t reproduce the original string “message” from hash value, so it’s one way cryptographic algorithm, it’s different than encryption that it’s  two way cryptographic algorithm.

How to Hash password …

Continue reading