asp.net mvc - why cant my enitity framework database work -
Hi, I was thinking that anyone can see what I am doing wrong. I am trying to create a database using the Entity Framework and then the seed, but getting errors
Ideal - this is a model in which I have made one and B class, in both the FK i dbcontext Try creating database
Namespace MvcAb.Models {Public class AaSeed: DropCreateDatabaseAlways & lt; AADb & gt; {Safe override zero seed (AADB reference) {reference.AssaAdd (new AA () {ANA name = "name", AADSC = "Big description", BBS = new list & lt; BB & gt; () {new BB (Bn = "this name", bbite = "this title"} // and new} // and list}}; // and new ay context.aas.ed (new AA () {name = "name Two ", AADSCC =" second desk "}; context.SaveChanges ();}} public class AaDb: DBcinTex {public dbet & lt; aa & gt; AS {receipts; set;} Public DbSet & lt; BB & Gt; BBS {Received;} Public AAADB (): Base ("AADB") {}} Public Class AA {Public IT Eyed {Received; Set;} Public String AaName {get; set;} Public string AaDesc { Get; set;} public list & lt; bb & gt; bbs {receipts; set;}} public square bb {public IT bbid {received; set;} public string bbName {get; set;} public string bbTitle { Get; set;} public AAAA {receive; set; rules Rk - This controller page that I create a new DB to connect me and then I introduce a list that will be displayed in my view private Aadibi db = new Aadibi (); // // GET: / Home / Public Performance Index () {Return View (DB.A. ToList ()); } // // GET: / Home / Details / 5 Public Action Details Details (Int ID) {Return View (DB FS (ID)); }
Index - this is my index where this table should be displayed and the data should be read
@model IEnumerable & lt; MvcAb.Models.Aa & gt; & Lt; Div class = "jambotron" & gt; & Lt; H1 & gt; Data Table & lt; / H1> & Lt; P & gt; @ * @ HTMLActionLink ("Create New", "Create") * @ @ / P & gt; & Lt; Table class = "table-table-range" & gt; & Lt; TR & gt; & Lt; Th & gt; Id & lt; / Th & gt; & Lt; Th & gt; @ Html.DisplayNameFor (model => model.AaName) & lt; / Th & gt; & Lt; Th & gt; @ Html.DisplayNameFor (model => model.AaDesc) & lt; / Th & gt; & Lt; Th & gt; & Lt; / Th & gt; & Lt; / TR & gt; @forcha (Miscellaneous items in the model) {& lt; Tr & gt; & Lt; TD & gt; @html DisplayForm (ModelItem => Item.Aid) & lt; / Td> & Lt; TD & gt; @html DisplayFull (Model Installam => Item.Aanam) & lt; / Td> & Lt; TD & gt; @html DisplayFor (Model Isthm = & gt; Item. AAADSC) & lt; / Td> & Lt; TD & gt; @ Html.ActionLink ("Details", "Description", new {id = item.AaId}) & lt; / Td> & Lt; / TR & gt; } & Lt; / Table & gt; & Lt; / Div & gt;
Make sure to go to Global. Do not see your code for this
database. Set Inchializer (new blog session);
And did you edit the connection string? add name = "AADB" provider name = "System.Data SqlClient" connectionString = "Data Source = (LocalBible) \ v11.0; I initial catalog = blogdib; integrated Security = sspi; "
Comments
Post a Comment