Reputation: 25303
I'm just starting a project in ASP.Net MVC with LINQ to Entities and I was wondering if there was a nice, clean way of defining models that creates the appropriate tables in the database for me. I'm most familiar with Django (in terms of MVC frameworks) and am looking for the .Net equivalent of models.py
so I can have everything versioned. Any ideas? It would be even better if it had some form of schema migration, a la django-evolution and the like.
Upvotes: 8
Views: 845
Reputation: 28402
I think what you want to do is to turn the question around. Entities can be automatically generated from the database, so the issue is simply using a .NET mechanism to maintain your database schema. Since you're not using NHibernate, which these other solutions require, I would suggest using MigratorDotNet. MigratorDotNet uses exactly the same idea as Ruby on Rails migrations:
Since you'll only be regenerating your Entities at compile time, I'd recommend running the migration scripts, and then regenerating your entities, as a part of your build process. MigratorDotNet already comes with an MSBuildTarget, adding it will just involve a couple of clicks.
Upvotes: 6
Reputation: 11391
Another option is to use NHibernate with FluentNhibernate which will auto map your model based on conventions. You can also override a mapping to tweak it for your needs.
Upvotes: 1
Reputation: 13707
Castle Project active record is a nice way of doing it.
If offers capabilities similar to ruby on rails active record.
Upvotes: 0