I will be building an application but I am not sure about what framework to use. At places where I have worked, they have used Ntiers with codesmith, nettiers being free but not codesmith. I found out about the Entity Framework but I have also read that the way to use it would be by using something called a “Repository Pattern” but there is a lot of doubts about using this. I do not have a big budget and its only myself, cant afford an expensive tool that would automatically create my classes with update, delete, create capabilities and leaving some code for me to implement. So I am not sure what way to go, should I go entity framework (is this the only one free?), or is there out there something else i could use, maybe not so expensive but reliable.
I would really appreciate a good advise on this as I expect, eventually this application will grow and grow and would like to be easy to maintain.
PS: I would go with entity framework and the repository pattern if that would be like my best choice.
Using C#, Asp.net and MSSQL 2008.
Entity Framework with code first and automatic migrations is one of the easiest ORM’s you can use. It’s flexible, well supported in the Microsoft stack, and with code first, one of the fastest ways of developing your database.
Using Entity Framework code first, you define your data models as just normal C# classes. This will correspond to the Product table:
Create a database context.
Add the connection string to Web.config, and run the commands in the package manager console:
And you now have a functional database with the Products table. When you make changes to your classes, just run Update-Database again, and it’ll migrate the schema for you.
To add a new product:
Querying your data becomes as easy as:
As for the repository pattern, it’s just a design pattern. There’s a lot of different variations of the repository pattern, but it’s really about separating your data stores from your data access layer. This makes unit testing easier, without having to rely on an external database being present.
Edit from your comment: There’s a couple ways of using EF and stored procedures. See Does Entity Framework Code First support stored procedures? and Using Stored Procedure to Insert Data.