For anyone familiar with Python/Django and the South migration module, I'm trying to find the asp.net MVC3 version if it exists.
What I'm trying to accomplish is create an entity, insert data, and in the future change my model and have the database incorporate the new data appropriately. I want to avoid manual SQL changes.
Does this exist in C# and is it reliable? I've read a bit about the DBInitializers, I'm not really okay with deleting all my data, test data or not, every time an entity needs an update.
Third party package is an acceptable solution (preferably from NuGet) if it has an active user base.
It sounds like you're looking for a good combo ORM and migrations tool. I'm not super familiar with Django, but I've done some work with Rails, and at a glance South looks a bit like ActiveRecord + rake. Does that sound accurate?
The best ORM I've worked with for .NET is EntityFramework 4.1 (i.e. - EF Code First) which is available here. It just happens to be the most downloaded package on NuGet.
Microsoft has released a migrations package for EF that's also available on NuGet. Scott Haneslman blogged about it a little while back.
You could also look into NHibernate as some people swear by it. I've personally never used it, but I've heard great things.
Hopefully that gets you started in the right direction.
// Edit
Doing a little bit more digging around on NuGet, I stumbled on Fluent Migrator which looks promising. Perhaps a better alternative to the EF Migrations package for now...
Related
we started a new ASP.NET MVC Project with EF and .Net 4.5. Original plan was to use code first to create the database, but that seemed a bit too complicated, probably mostly because all of us were familiar with DB-designs and it seemed just much easier and faster to do everything in SQL.
So for now we use EF to simply create mappers for our tables, views and functions. Stored Procedures don't really want to work for us automatically, so we are calling those manually with SqlCommand. Now a problem sometimes emerges with the complex connection string and all the XML-files which need to be referred in it. (At least which are referred when we use the automatically created connection string).
Long story short - EF has many features, of which we probably use only a hand full. We would be probably much happier with Linq2Sql. But that one is obsolete, and few months ago I read some scary posts, that when you want to launch your application in Azure, DB connections can break, and EF (from version 5 or 6) is so awesome and renews them automatically.
Is this true and EF the only usable ORM mapper for azure? Can we somehow deactivate all those features we don't use to have something as simple as Linq2Sql, should we use directly Linq2Sql even though it is obsolete, or just learn to deal with all those features? Or is the answer to use NHibernate (which seems to have a much more straight forward XML-configuration file, but no simple integration with Visual Studio to create all necessary classes)?
Update:
Another reason we gave up on code first and reverse engineered code first was, that we were missing an easy way to create wrapper functions for our SQL Server - stored functions. This feature is provided with the DB-first use of EF (as we use it)
My team is looking to shift asp.net form application from .NET 4 to .NET 4.5. We are hoping that we would be able to use the whole new Entity Framework 5. Being the in charge of this task I did look into the advantages of using EF5 and I am quite impressed.
EF5 gives you the ability to run pre-compiled Queries and that will be a great performance boost.
Apart from that we would be able to use enums and table-valued functions, that I am not very excited about but lets see how these can improve Code Quality and maintenance.
My Question is, are there any good resources that can help me learn some practical implication of EF5. I have been searching for some time and hope that there are people out there who have already jumped to EF5 and can post some useful resources in here.
The answer is not exactly about EF but for "MVC with EF".
I'm learning MVC these days & I've learned quite a bit. I would like to share my experience and how the whole training can be highly effective. If you go systematic, everything is simple and cool. I would advise you to first cover some basic concepts which are used in MVC and entity framework:
Extension Types
Lambda Expression
LINQ
Anonymous Types
You can find good information on these at http://www.youtube.com/watch?v=FejRZ6QYWHw.
If you already know that you can skip.
Next you can start learning the EF. You can do so by following Lynda Tutorials which I found to be extremely simple and effective (avoid Plurasight as of now).
You can also visit asp.net website and check the Getting started with EF6 using MVC 5. It has wonderful list of articles, which I would recommend to everyone.
And once you are done with that, you should be capable enough to build any web application. If you want more higher level details you can then opt for Plurasight tutorials.
Hope this helps.
I want to use NHibernate with Asp.net 3.5 but i don't know how to use it.I search on
Google but couldn't find the complete explanation about why to use NHibernate,Advantages of using it and integration with Asp.net projects.
I would suggest checking out Castle and NHibernate. I recently started using it and was blown away with what it can do. Castle manages all your sessions for you. Also it is easy to use LINQ with it.
Check out
http://davidhayden.com/blog/dave/archive/2008/04/28/NHibernateCastleActiveRecordTutorialUninitiated.aspx
Another great tool to use (Should work with ASP.Net) is the Nhibernate Profiler
http://nhprof.com/ It shows you what queries are being generated and the time its taking to run.
Also if you already have your database created you can download this tool http://www.agilityfororms.com/Home/Products/AfoCastleActiveRecordModelCodeGenerator/ It will create your models based on your database. Its works great for the most part. Although you have to register to download the free version still worth checking out.
Fluent NHibernate is supposed to be good as well although I have no experience with it. Might be worth checking out. http://fluentnhibernate.org/
You could have a look at this :
http://www.codegod.de/WebAppCodeGod/nhibernate-tutorial-1---and-aspnet-AID25.aspx
And this :
http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx
I'm nearing completion of my first project with it, and I've had mixed results. For basic data persistence, and assuming you already knew how to use it, it's much faster to build an application with it. You don't really have to worry about building stored procs and differentiating between new objects and updated objects.
On the other hand, until you're quite comfortable with it, it can take a long time to do something that would have been simple before. I've had a couple of problems, and it has been difficult and time consuming finding solutions to them.
To be fair, I've only written small applications with it and it has made the development process more difficult than I would consider required. The pain of using it is fairly similar from one app to the next, the benefits scale...
The best place to look is at NHibernate Forge. There's Blogs, wikis and groups that will help you out.
As for advantages of using it that is something you need to workout for yourself. Is it more advantageous than LinqToSql or Entity Framework? It depends on the project size and what you are actually looking for.
I'm working on a new project right now and am thinking of using an ORM beyond that of Linq to SQL. I've currently got Linq to SQL wired up into a repository, but I'm not loving the way my Repo has to match my DB structure. (Example: I have a join between Users and OpenID's, and I need a 2 classes ( one for each table) and a class for the View that joins them).
I've heard some good things about Telerik's OpenAccess ORM and I do have a license for it (though outdated - Latest Version: 2009.1 405 (Apr 5, 2009))
My questions are...
Has anyone used it?
How is the learning curve?
Is it a good tool for my above scenario?
Is the version I have ok without having to update my license?
Our company is a $2.5B solar manufacturing company. When we started designing v2 of the application framework backend that all our applications would be based on, we took a look at the Telerik ORM. I spent a couple weeks looking at it. Our conclusion was that it was too complex, and a little flaky, for our needs. We went with L2S and have not regretted it. L2S has provided all the capabilities we need and is simple and straight forward. IMO, it's too bad Microsoft is spending so many resources on Entity Framework, because they have a winner in L2S.
Which orm you would recommend for a beginner moving from ado.net?... Thus far used ado.net stored procedures with asp.net and now like to move with an orm.. Any suggestion..
NHibernate is nice, but it does require a bit more configuration for the ORM (even though fluent NHhibernate is quite nice).
I have heard that beginners in .NET ORM's have had quite good success with Subsonic: http://www.subsonicproject.com/.
NHibernate. The new development branch - much better support for LINQ than the current released versions.
At the risk of sounding odd - why not http://msdn.microsoft.com/en-us/library/bb425822.aspx??
Yes, I know - Microsoft has officially said there wouldn't be much more development on it - even though it was bugfixed and enhanced in .NET 4. It's still in .NET 4 - so it'll be around for at least 3-5 years. It's easy to use - much easier than NHibernate - with a visual designer and code generation.
It's simple and easy to understand, and it can give you a great intro to using an ORM.
Once you've learned, internalized, and understood the principles, you can always move on to a more enterprise-ready solution, like NHibernate, or Entity Framework v4.
See Scott Guthrie's excellent blog post series on Using Linq-to-SQL for a great intro, or check out the Nerddinner tutorial which showcases ASP.NET MVC and Linq-to-SQL.
NHibernate is currently one of the most popular ORM's, but Microsoft has been busy working on Entity framework. In time this may become the most popular and the best simply because it comes with .Net Framework.
I'd second the LINQ2SQL option if you're using SQL Server.
LINQ2SQL:
is easy to learn, with lots of guidance available online;
has good tooling for design and debugging in Visual Studio; and
provides adequate performance for all but the most extreme of situations (StackOverflow uses it for data access, for example).
There have been rumours of its demise for a while, but Microsoft's market research seems to show more developer support than for Entity Framework which, whilst arguably more powerful, is also more complex. LINQ skills are transferable to other ORMs too, with options for LINQ2Entities (for Entity Framework) and, I believe, support from SubSonic also.
Entity Framework
Definitely try that out. Solid support from Microsoft themselves, support for Many-to-Many relationships, eSQL lets you at the lower layers, etc.