locked
MVC - Connection to Database RRS feed

  • Question

  • User924117947 posted

    Hey Community.

    I'm having some problems with ASP.NET MVC3 (C#). I'm trying to mix all Models to a once Database in diferent Tables
    (Like UserModel goes to table Users, PostModel goest to table Posts..). Also, i don't wanna use the default MVC Database (aspnetdb.mdf, which is the default database for the MVC Login System).

    First of all, i can't connect to my Database properly, it's a SQL Server Database. I already created the database connection in Server Explorer, but i can't add it to App_Data. I'm trying to add an Existing Item, but it shows "Acess Denied".

    How can i add the database inside the App_Data?

    ____

    Also, after solved the first problem, how can i say which Table goes to which Model? (For example, UserModel goes to table Users, PostModel goest to table Posts..)

    Thanks for you help, i'm a newbie in MVC. =)

    Wednesday, May 30, 2012 3:44 PM

Answers

  • User197322208 posted

    Thanks for you help, i'm a newbie in MVC. =)

    THis is EF, not MVC.

    how can i say which Table goes to which Model? (For example, UserModel goes to table Users, PostModel goest to table Posts..)

    There is not so simple. You can try EF Code First ( search for that)
    However, being a newbie, I think that:

    1. You can map the name of the class to the name of the table

    2. Follow tutorials from http://www.asp.net/mvc

    3. Understand the ViewModel is not Database Model http://msprogrammer.serviciipeweb.ro/2010/03/29/asp-net-mvc-orm-and-viewmodels/

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 30, 2012 5:15 PM