Saturday, June 29, 2013 with Model First Entity Framework, Oracle DB

These days I started working on developing a website from scratch using MVC4 and Entity Framework. I was planning to use Oracle database and realized that "officially" only Model-First entity framework approach is supported so decided to go ahead with that only.

As soon as I started working on developing database, I realized most of the examples or knowledge resources are based on Code First approach and Model First resources are very scarce. Considering that I decided to prepare a document listing all of my major issues with the links that helped me in fixing the same.

I am using MVC4, Razor, BootStrap, Model-First Entity Framework, Oracle db.

As the list of issues is extensive, this document is not even 1% of total issues but I believe over the time I will improve it and will definitely help some.

Google Doc: MVC4 with Model First EF, Oracle, Razor, Bootstrap from scratch

Tuesday, June 18, 2013

Nullable vs int?, C#

Today I generated code from the designer surface using DbContext template and realized that all of my nullable fields are declared as Nullable<int>. Kind of surprise to me "why it did not declare <int?>".

Found that both syntax are similar and there is no difference between the operation of two syntax. So feel free to use any one of them. They both represent an integer variable which can have null value too.

Mind, there is a difference between having a default value i.e. 0 or being null.

Friday, June 14, 2013

edmx file orgainzation, Entity Framework

Many times you are in need of making change in edmx file xml instead of simple designer surface. To get better understanding of how edxml's XML is organized, here is a brief overview.

edmx file is composed of three separate entities:

  1. Store details (SSDL Content): Content of this xml section has information about your database, what all tables are included in database, their column names, data types etc.
  2. Conceptual Model (CSDL content): This xml section has information about all properties and entities that you see in designer surface of a model in visual studio. For example you create a property of an entity named "comment" and declare it of "string" type. Now conceptual model will store details as "comment" -> "string". However Store Model will store the same property as "comment"-> "nvarchar2" (assuming comment is <2000 chars) i.e. datatype of property in SQL table.
  3. Conceptual - Store Mapping (C-S Mapping Content): It has information about mapping between the above two described model.
XML Organization:

<edmx: StorageModels>  Store Model (SSDL) details
     -- Entity Type        Table Name for an entity
                -- Property           Column name for a property 
     -- Association        Association table declaration i.e. relation b/w two tables.
                -- Referential Contraint        table's column declaration.

<edmx: ConceptualModels>       Conceptual Model (CSDL) details
     -- EntityContainer
                 -- Entity Set
     -- Entity Type          Class declaration for an entity
                 -- Properties       Property of model class

<edmx: Mappings>            C-S Mapping details
     -- EntityContainerMapping
                 -- Entity Set Mapping            Entity name; table name, class name for entity
                            -- Entity Type Mapping
                                     -- Mapping Fragment
                                                -- Scalar Property             Relation b/w CSDL table property and SSDL table column

Thursday, June 6, 2013

Using ORACLE database with Visual Studio for ASP.NET MVC4 website using Entity Framework

These days Microsoft's ASP.NET MVC4 is being used for latest cutting edge website development. Because of the ease that Entity Framework provides it is very well adopted by the developer community. Though it is fully compatible with Microsoft SQL Server database and other databases are still trying to provide support of EF. In case you want to use Oracle with Entity Framework then you need to install Oracle Data Access Components (ODAC) and Oracle Developer Tools.

Please note, as of now, Oracle support for Entity Framework only supports Model First approach. Though there are ways to approach Code-First too but it is not very well supported yet.

To install ODAC and ODET, it might get somewhat confusing and reaching to the appropriate knowledge document might get difficult. Here is the link by Oracle discussing how to install .NET components:

Share your experience with installation.

Wednesday, June 5, 2013

Ruby on Rails learning resources

I started learning Ruby on Rails last year and till date I'm still learning more on it. Here are few good online resources which I found helpful:

  1. First Ruby book I read:
  2. Agile Web development with Rails: Amazon link. I really like this book because of pragmatic approach. Worth buying.
  3. Code School 
  4. Once been through above books I started working on an Open Source project and where I believe actually I got chance to implement what I've learned so far.
  5. Revision after a break of 3-4 months from Ruby I again started learning from CodeAcademy which I found very wonderful and easy to learn tutorials.
  6. Also I've just started reading this book which now I believe is must read for a ruby enthusiastic. 
Will add more resources as I will find any but I guess if you are done with all these then you are at pretty much good level in programming RoR.