SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict darkwater23's Avatar
    Join Date
    Nov 2005
    Location
    Omaha, NE
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question MVC & Entity Framework

    Hey, guys!

    I'm kind of confused by something and I thought someone here could explain it. I've been researching this for a while now and I can find the answer.

    I have a SomeDatabase.edmx file in my MVC3 project where I connected to a database and imported all the entities. Later, I created a stored procedure and mapped that function. The only way to access the database class was to do "Add an existing item" on the Models folder and point to that edmx file. It looks weird to me, though, because I can see the file in my project twice now. Once in the root and once under models. If I make a change (like when I added the sproc), rebuilding the project didn't expose the method. I had to remove and re-add the edmx file to models. That doesn't sound right, so I think I did something wrong.

    What is the proper procedure for using EF and MVC3? Thanks!

  2. #2
    SitePoint Addict darkwater23's Avatar
    Join Date
    Nov 2005
    Location
    Omaha, NE
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok, I think I found it!

    Create an Entity Framework Model and Use it in Multiple Projects

    I created a class library and then created the model in that new project. Then, I referenced that project in my MVC project. I'm going to proceed from here and see how it goes.

    Wish me luck!

  3. #3
    SitePoint Addict darkwater23's Avatar
    Join Date
    Nov 2005
    Location
    Omaha, NE
    Posts
    335
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Found one gotcha! Since I had mucked up the project pretty good, I burned it down and started over. There's an issue with adding MVC to an existing solution, though.

    Problem adding new project to MVC solution : The Official Microsoft ASP.NET Forums

    One suggestion was to add two projects so that you can view the solution tree in VS2010 and then add an MVC project to it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •