locked
Adding content to an mvc project started with aspnet Identity RRS feed

  • Question

  • User-2006371901 posted

    I have started a new mvc5 project with the Identity configured, SQL database with the appropriate tables to take in aspnet logins, roles etc. From the home index.cshtml page, i need to add content taken from a database (job listings), which will come from a Jobs table in the database. I have problems trying to start a new template that will merely just take all the available job listings onto the index.cshtml page. I have not found any online resources that show how to do this after integrating aspnet identity succesfully.
    Thanks in advance

    Ned

    Wednesday, May 15, 2019 6:21 PM

All replies

  • User1120430333 posted

    Norkle

    I have started a new mvc5 project with the Identity configured, SQL database with the appropriate tables to take in aspnet logins, roles etc. From the home index.cshtml page, i need to add content taken from a database (job listings), which will come from a Jobs table in the database. I have problems trying to start a new template that will merely just take all the available job listings onto the index.cshtml page. I have not found any online resources that show how to do this after integrating aspnet identity succesfully.
    Thanks in advance

    Ned

    Well, you don't have a template and code generator that is going to take another database and have things done for it like you have seen things done for the Identity database. The other database is standalone and separate from the Identity database and its MVC code. You're going to have to make your own MVC logic, roll your own code, make your own database and do it.

    One thing that  you can get you started is use the Service Based Database feature in VS. Actually,  in creating the ASP.NET MVC solution that created the Identity database via  a template, it used a form of the Service Based Database  and created the Identity.MDF file, which a Localdb database.

    https://docs.microsoft.com/en-us/visualstudio/data-tools/create-a-sql-database-by-using-a-designer?view=vs-2019

    The database that you will create will be a Localdb database.

    https://docs.microsoft.com/en-us/sql/database-engine/configure-windows/sql-server-express-localdb?view=sql-server-2017

    Once you get the database created, then you have to make a decision on how you going to code to access that database and its tables. Are you going to use ADO.NET and SQL Command objects using T-SQL? Are you going to use the ADO.NET Entity Framework that it the preferred way of database access using ASP.NET MVC?

    Wednesday, May 15, 2019 7:00 PM
  • User475983607 posted

    I have started a new mvc5 project with the Identity configured, SQL database with the appropriate tables to take in aspnet logins, roles etc. From the home index.cshtml page, i need to add content taken from a database (job listings), which will come from a Jobs table in the database. I have problems trying to start a new template that will merely just take all the available job listings onto the index.cshtml page. I have not found any online resources that show how to do this after integrating aspnet identity succesfully.

    Your question is not clear.  I assume you created a new project using the Individual Account settings which populated the Identity templates and data store.  You have another table in a different DB that has Job Listing and you want to access this existing DB in your new Identity project.

    The following explains how to integrate an existing DB using EF 6.  

    https://docs.microsoft.com/en-us/ef/ef6/modeling/code-first/workflows/existing-database

    Wednesday, May 15, 2019 7:09 PM
  • User-2006371901 posted

    I need to re-create the index.cshtml to simply take data from another table in the sql database (which I have configured to be remote on a shared hosting server)  and display it.  I have already set up the project to allow logins, register users, etc.

    Wednesday, May 15, 2019 8:14 PM
  • User475983607 posted

    I need to re-create the index.cshtml to simply take data from another table in the sql database (which I have configured to be remote on a shared hosting server)  and display it.  I have already set up the project to allow logins, register users, etc.

    The problem you are trying to solve is still unclear. 

    Are you trying to scaffold the Index View using an Entity?  If you followed the previous link and reverse engineered the Entities then scaffolding a View is just a few clicks.

    Wednesday, May 15, 2019 8:23 PM