2

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?

2
  • 1
    You should think about working with Entity Framework Code First. It will become much easier to make changes as you proceed. Commented May 7, 2013 at 17:44
  • So what I've used now, I need to re-create the edmx if the database structure changes? Commented May 7, 2013 at 18:19

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

Well I followed this example. hectorea.com/blog/…. The application I am building is reading from an existing database, that may encounter db changes later down the road but no known changes at the moment. Although there may be database changes later, I was just thinking of deleting the EDMX file and just re-creating it again.
reading this example. weblogs.asp.net/scottgu/archive/2010/07/16/… I am just trying to understand how the model obtains the database changes. If you are dropping the database and recreating the model, won't the rows in the database also be lost?
@foop the first link you mentioned is Db first, i wouldn't start there if not very experienced. The 2nd link is Code-first. It doesn't necessary drop the database, it rather updates it. Thats the best part of using code first and migration. If you watch the pluralsight video, you will know when i mean.
dotnetcurry.com/ShowArticle.aspx?ID=889 I started reading up with this, and now get what you are talking about =) I will get my company to pay for the pluralsight subscription when my manager gets back. This is really neat, it created my table even though the database didnt have it. Magic...
1

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.