Saturday, May 7, 2016

Don't try to code first with the Code First Entity Framework paradigm.

The disenchantment I express here is really do to with attempting to code first and then have C# objects build out my database. The Code First paradigm is really just a badly named move closer towards an NHibernate way of doing things away from that .edmx thing. If I don't despise NHibernate for not letting me just model in C# then I guess I shouldn't despise Entity Framework for the same "shortcoming" either. Just write SQL to make your tables and then interface with the database you've built out with your SQL from Entity Framework. This will take some getting used to as you learn what Entity Framework wants C# getsetters to map to in the SQL space. A DateTime is to dance with a not null datetime while a nullable DateTime will dance with a datatime column where you can have nulls. A string in C# seems to correspond to a nulls-are-just-fine nvarchar of max length. I don't know how to change that yet. If you want to make a primary key restraint to tie one table to another and have it represented in C#, I have no idea how to make that happen either. Whatever. fun fun!

No comments:

Post a Comment