I see a lot of this going on in MVC3 while using the Entity Framework but it looks like a LINQ to SQL model.
public class SomeClass {
public int Id { get; set; }
public string username { get; set; }
public string password { get; set; }
}
Why and when is this type of model necessary while using the EF? Everything I’ve ever needed to do in a controller while using the EF, I’ve done with EF as my model, isn’t that what the EF is for, so you no longer have to write L2S style models???
Am I getting confused thinking I’m looking a tutorial using the EF but it’s really using L2S or am I missing something???
Confused,
Mike.
Torm, you are a champ! And +1 to Jan as I read that first, it makes sense although I haven’t come across a scenario when I’ve had to do so, and no longer felt I was missing something.
But Torn has it. Code first, what the %&*$!
The first tutorial I did in MVC # something, I created a database, filled it with dummy data (that takes time) but it was a code first tutorial, I ran the app and all the dummy data was gone!!! I have no idea why there is a code first option, I always start an app with a database. I guess it’s for people who work in a large company and don’t have access to the database while writing MVC??? Even so why not build a dummy database for testing, I always do? I will ask that question in another post.
So all the model classes for a database first approach with EF are automatically generated in the Model/.Designer.cs file! And therefore you don’t need to write L2S style models at all, EF does it all for you.
I think I know everything there is to know about MVC now, not!
Cheers,
Mike.