Sunday, 15 May 2011

sql server - Addig a SQL Database to ASP.NET MVC -


I'm trying to connect my SSP server (SQL Server 2014 MGT Studio) to my ASP.NET MVC (VSAPS3) but to be unsuccessful

! This is the code I have installed, but I do not see the data from Systemview.Data.Entity.ModelConfiguration.ModelValidationException 'or the data from the table shows'. Any help would be greatly appreciated - I've attached my code below:

Model:

  Using the system; Using System.Collections.Generic; Using System.Linq; Using System.Web; Nameshot Global Matriculation 2.Modals {Public Class GMUSALong {Receive Public Virtual IT BID; Set; } Public Virtual String BMetrics {get; Set; } Public Virtual String BTopic {get; Set; }}}  

context:

  using the system; Using System.Collections.Generic; Using System.Linq; Using System.Web; Using GlobalMetricsTest2.Models; Using System.Data.Entity; Namespace Global Matrix 2.DAL {Public Class GMUSALongContext: DbContext {Public DbSet & lt; GMUSALong & gt; GMTest {get; Set; }}}  

Controller:

  using System.Web; Using System.Web.Mvc; Using GlobalMetricsTest2.DAL; Using GlobalMetricsTest2.Models; Namespace Global MatrixTista 2. Controllers {Public Sector GMUSALongController: Controller {Private GMUSALongContext DB = New GMUSALongContext (); Public Performance Index () {var advItems = db.GMTest; See refresh (advItems.ToList ()); }}}  

See:

@modelimimableable & lt; Global MeteorityTest 2 Models.gmUSLlogg> @ {ViewBag.Title = "Index"; Layout = "~ / scene / share / _Layout.cshtml"; } & Lt; H2 & gt; Index & lt; / H2 & gt; & Lt; Table & gt; & Lt; TR & gt; & Lt; Th & gt; Id & lt; / Th & gt; & Lt; Th & gt; Metrics & lt; / Th & gt; & Lt; Th & gt; Subject & lt; / Th & gt; & Lt; / TR & gt; @Forcha (Model Item in the Global Metricist Model 2.) {& lt; Tr & gt; & Lt; TD & gt; @ Item.BID: & lt; / TD & gt; & Lt; Td> @ Html.DisplayFor (ModelEystem => Items.Bamatrix) & lt; / Td> & Lt; Td> @ Html.DisplayFor (model item => items.bottical) & lt; / Td> & Lt; / TR & gt; } & Lt; / Table & gt; From the initial perspective, I advise you to try another approach. I

Create a database table according to your wishes, then navigate to new projects - Create a templated MVC project, select ASP.NET web application. You will get a prompt with further options, select 'MVC' This will give you a good template example that you can refer to for any MVC questions. Creating a new project and adding MVC 5 with NUGET will start a cleaner example, but more steps will be required.

Now that you've created your website, right-click on your 'Models' folder, select Ad -> New Item, select ADOnet Unit Data Model, you will get a prompt with more options,' Database Select the code before, provide the information of your database connection, imported like D, at this point you have functional data reference with all the necessary annotations allocated for a non-standard naming conventions needed.

Now right-click on your 'View' folder, click on Add-> 'New Scofolded Items'. Select 'View MVC 5', give your view name (I recommend the name of your model + 'view'), which model you want to use, choose which type of screen you want to make, List ' Once created, you will find a good standard example of all the pieces you want to learn. After obtaining the knowledge you need, you can make minor changes to this process to create a highly functional screen for your site.


No comments:

Post a Comment