I have been using Subsonic with MVC.NET and love the feature that allows me to generate a database from the c# classes. This is great because it allows you to think about the app first and the data second.
Now that I am moving onto MVC.NET 2.0 - I am using the features in the Entity Framework which are great giving form validation client and server side natively.
For example, I have a class in my model...
public class StackOverflow {
[Key]
public int PropertyID { get; set; }
[Required(ErrorMessage = "Title Required")]
[StringLength(50, ErrorMessage = "Must be less than 50 charceters")]
public string Title { get; set; }
}
...my question is, can I use the c# class to define the edmx and then use this to generate the database?
Also, if this is possible - is this good practise?
Edited to add.. Just to clarify, with Subsonic I can go into the controller as add
var sof = new StackOverflow();
sof.Title = "Lorem ipsum dolor sit amet";
var repository = new SimpleRepository("connString", SimpleRepositoryOptions.RunMigrations);
repository.Add(sof);
and my database is created, is there no way to go from class to model or class to dbase or is creation of this a separate activity?
Im t开发者_如何学运维rying to follow the m$ EF model as I beleive this will be that way MVC3 will go and Subsonic while great for speed (and making $$$) will render me out of date quickly.
Do I need to choose between ef4 or Subsonic and an alternative validation model for now?
It seems that the 'EF Magic Unicorn' is in CTP4.
more information here and here.
精彩评论