Monday, February 24, 2014

Data Validation in Entity Framework

Validating data is important to make sure bad data is not getting into the system causing unnecessary troubles. When developing applications using Entity Framework, you can use features in .NET and Entity Framework to ensure only valid data will flow through it. Here we'll see what features we can use with Entity Framework to do our job

Using Data-Annotations

Data-Annotations are attributes you can add to property or a class. Data-Annotations are not a feature comes with Entity Framework. It's a feature of MVC. You must add System.ComponentModel.DataAnnotations to use this. 


IValidatableObject

Its is an interface which can be applied to a class. 

ValidateEntity


DbUpdateException

Exception throws by Entity Framework when updating to the database gets fails

References



updated November 2014

Saturday, February 22, 2014

Interesting Findings in SQL Server

Interesting findings articles gives small tips and findings 
you can use for the particular technology


Difference between datetime and datetime2 (SO)
DATETIME2 has a date range of "0001 / 01 / 01" through "9999 / 12 / 31" while the DATETIME type only supports year 1753-9999
DATETIME2 is more accurate when compared to DATETIME

What is LocalDB
This was introduced in SQL Server 2012. It's basically a new version of SQL Server Express intended for developers so you don't need to install SQL Server. 
http://stackoverflow.com/a/18781150/340046
http://blogs.msdn.com/b/sqlexpress/archive/2011/07/12/introducing-localdb-a-better-sql-express.aspx

MDF File
It is SQL Server data file. 
http://stackoverflow.com/questions/1175882/what-is-an-mdf-file

SQL Server Service Broker
Provides native support for messaging and queuing application in SQL Server Database engine. Developers can use Service broker to distribute data workload across databases. (See MSDN article)

YouTube Results for SQL Server Service Broker

Delete options for Tables
You can specify what to do when you delete a row in a table.
CASCADE : Corresponding tables are updated
see column_constraints.
http://stackoverflow.com/questions/17976689/do-i-need-to-specify-on-delete-no-action-on-my-foreign-key
http://www.techonthenet.com/sql_server/foreign_keys/foreign_delete.php
http://stackoverflow.com/questions/59297/when-why-to-use-cascading-in-sql-server
http://stackoverflow.com/questions/278392/should-i-use-the-cascade-delete-rule
http://stackoverflow.com/questions/3656099/how-to-delete-rows-in-tables-that-contain-foreign-keys-to-other-tables
https://technet.microsoft.com/en-us/library/aa902684(v=sql.80).aspx

SQL Server Agent
Component of SQL server which schedules jobs and handles other tasks. SQL Server Agent runs as a windows service.



Wednesday, February 5, 2014

Evolving of ASP.NET Identity System

ASP.NET Membership Provider


SqlMembershipProvider
Manages Membership information in a SQL Server database

ActiveDirectoryMembershipProvider
Manages and store membership information in Active Directory.

LDAP  (Lightweight Directory Access Protocol) : Is a protocol used to talk to AD (Difference between AD and LDAP)

Both providers above implements MembershipProvider class. Also see how to use AD and SQL providers together here and here.

ASP.NET Simple Membership

Membership system for ASP.NET Web Pages
Can't use with OWIN
Doesn't work well with existing ASP.NET membership providers

ASP.NET Universal Providers

Persist membership information on Windows Azure SQL Database
Can be used to persist data in any store built on Entity Framework
Built on ASP.NET membership infrastructure
http://www.asp.net/identity/overview/migrations/migrating-universal-provider-data-for-membership-and-user-profiles-to-aspnet-identity

ASP.NET Identity

One ASP.NET identity system
Unit testability
Ease of plugging in profile data about the user
Role provider and claim based
Social login providers
Windows Azure Active Directory
OWIN integration
NuGet package

DotNetOpenAuth
http://stackoverflow.com/questions/tagged/dotnetopenauth

Resources
Windows Identity Foundation 
Introduction to Membership
Membership class
http://brockallen.com/2013/10/20/the-good-the-bad-and-the-ugly-of-asp-net-identity/
http://stackoverflow.com/questions/21207246/asp-net-identity-vs-simple-membership-pros-and-cons
http://brockallen.com/2012/09/02/think-twice-about-using-membershipprovider-and-simplemembership/
http://weblogs.asp.net/jongalloway/simplemembership-membership-providers-universal-providers-and-the-new-asp-net-4-5-web-forms-and-asp-net-mvc-4-templates

Powered by Blogger.


Software Architect at Surge Global/ Certified Scrum Master

Experienced in Product Design, Software Engineering, Team management and Practicing Agile methodologies.

Search This Blog

Facebook