Saturday, 16 April 2011

Entity Framework

It's been quite a while since I've last updated this blog, but trust me, there were pretty good reasons for that.

Today I'm checking out the Entity Framework. I decided to give it a try, and see how it will be going.
At first I was quite happy with the results. With no efforts at all I was able to create this conceptual model out of my handcrafted database I was quite proud of:


And it seemed to make quite a good job generating my database back from the model.
However, having analyzed the results more carefully, I've come across some not really encouraging results:


1. Table names were pluralized regardless of original names being singular
2. Constraints were lost (CHECK (Color >= 0 AND Color < 12))
3. Primary/foreign key constraint names were lost (CONSTRAINT CategoryIdPK PRIMARY KEY NONCLUSTERED (Id))
4. Primary key was created as clustered
5. Real clustered index has gone (CREATE CLUSTERED INDEX CategoryUserNameIdx ON dbo.Category (UserName ASC))
6. SMALLDATETIME was automatically changed to DATETIME
7. Non-clustered indexes were created on foreign keys despite they were missing in the database (which is kind of good, and it was my fault not to create them)
8. ON UPDATE CASCADE were created as ON UPDATE NO ACTION (while it might be discussible which is right for cross-table foreign keys, still, I don’t support such an initiative).

Well, it is not like you won't be able to create a product with Entity Framework, but for sure you won't be converting your schema back and forth every so often.

No comments:

Post a Comment