foop
foop

Reputation: 523

MVC 4 Entity Framework Models

I'm a bit confused when creating/organizing an Entity Data Model in Visual Studio.

Currently I am creating a custom User Login page to go along with my existing database. When I created the Data Model, I go through the generation wizard log into the database, and then it asks what tables I want to include.

I ended up selecting the user tables and the roles and user type tables and was able to successfully authenticate and such.

Now I want to add additional functionality and call to other tables in my database. Should I be creating a brand new Entity Data Model? Or should I just select all the tables in my database?

Upvotes: 2

Views: 829

Answers (2)

Komengem
Komengem

Reputation: 3764

As someone who likes to write my code, i would encourage you to work with Entity Framework Code First. Unless, you have all your app planned out, this is the best approach as it simplifies making database changes very easy.

It looks like you have either been doing Model First or Database First. To see the differences between all 3 of them See This Post

Follow here to see Entity Framework Code First at work. This is a PluralSight video, there is a free trial you can use

Since you mentioned login, i should also advise to use the built in Simple Membership. You can integrate it into your current model with easy.

I recently answered this question on Simple Membership and provided some links that helped me once.

If you have questions, i would be happy to answer them.

Upvotes: 1

Stephen King
Stephen King

Reputation: 836

Unless your database is huge, I would just keep everything in the same EDM, it will make it easier to do joins, and traverse the relationships. You can however have multiple EDMs share a context.

[1] https://softwareengineering.stackexchange.com/questions/164128/entity-framework-with-large-systems-how-to-divide-models

[2] Multiple/Single *.edmx files per database

[3] http://forums.asp.net/post/3591202.aspx

Upvotes: 1

Related Questions