{"id":72,"date":"2009-04-20T22:13:25","date_gmt":"2009-04-21T02:13:25","guid":{"rendered":"http:\/\/pattersoncprod.wpengine.com\/?p=72"},"modified":"2009-04-20T22:13:25","modified_gmt":"2009-04-21T02:13:25","slug":"using-mysql-with-entity-framework-and-aspnet-mvc-part-ii","status":"publish","type":"post","link":"https:\/\/pattersonc.com\/?p=72","title":{"rendered":"Using MySQL with Entity Framework and ASP.NET MVC &ndash; Part II"},"content":{"rendered":"<p>I am going to wrap up this two part series on using MySQL with Entity Framework. Below is a link to the initial installment.<\/p>\n<p><a href=\"http:\/\/pattersoncprod.wpengine.com\/index.php\/2009\/04\/01\/using-mysql-with-entity-framework-and-aspnet-mvc-%E2%80%93-part-i\/\" target=\"_blank\" rel=\"noopener\">Using MySQL with Entity Framework and ASP.NET MVC \u2013 Part I<\/a><\/p>\n<p>In Part I, we created a database schema in MySQL, generated a data model using Entity Framework, and wrapped the model using a simple repository pattern. We will now walk through using those repositories to access and modify our data.<\/p>\n<p><strong>Extending our <strike>repositories<\/strike> data model<\/strong><\/p>\n<p>Due to the fact that the default MySQL database engine does not support foreign keys, there is no relationship between the two entities generated by Entity Framework. After a frustrating experience trying to manually add the association for Product-&gt;Category using the EF designer, I decided to add it manually by extending the generated partial class. This will allow us to easily access the category to which a product belongs.<\/p>\n<div class=\"csharpcode\">\n<pre class=\"brush: csharp;\"> public partial class Product\n {\n     private Category _category;\n\n     public Category Category\n     {\n         get\n         {\n             if (_category == null)\n            {\n                var categoryRepository = new CategoryRepository();\n\n                var cat = categoryRepository.Select(categoryid);\n\n                _category = cat.First();\n            }\n\n            return _category;\n        }\n    }          \n}\n<\/pre>\n<pre>&nbsp;<\/pre>\n<\/div>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p><strong>Using the MVC pattern<\/strong><\/p>\n<p>If you are unfamiliar with MVC pattern, I suggest you check <a href=\"http:\/\/en.wikipedia.org\/wiki\/Model-view-controller\" target=\"_blank\" rel=\"noopener\">this<\/a> out for a little background. Also, information specifically concerning ASP.NET MVC can be found <a href=\"http:\/\/www.asp.net\/mvc\/\" target=\"_blank\" rel=\"noopener\">here<\/a>.<\/p>\n<p>We have already fulfilled the &#8220;M\u201d in MVC by generating our model using Entity Framework. These objects will serve as a strongly typed data model for the database we wish to access. The next step is to define the behavior of our sample application. This will be done in our Controller objects, the \u201cC\u201d in MVC.<\/p>\n<p><strong>Working with ASP.NET MVC<\/strong><\/p>\n<p>When we created our new ASP.NET MVC project, a few folders were created automatically. As we have seen already, a <em>Models<\/em> folder was created and can be used to store the code files representing our data model. To create our Controllers, we are going to right-click on the <em>Controllers <\/em>folder and select <em>Add-&gt;Controller\u2026<\/em> Here we will create a new controller named ProductController and tick the option to automatically generate Create, Update, and Delete stubs. (Note: We are going to use the default routing table that ships with ASP.NET MVC. This can be edited in Global.asax.cs)<\/p>\n<p><a href=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmpd5c8.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"tmpD5C8\" border=\"0\" alt=\"tmpD5C8\" src=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmpd5c8-thumb.png\" width=\"403\" height=\"164\"><\/a><\/p>\n<p><strong>Listing our data<\/strong><\/p>\n<p>To generate a list of our data we are going to place the following data fetching code into the Index method stub of our Controller and pass the results to a View.<\/p>\n<div class=\"csharpcode\">\n<pre class=\"brush: csharp;\">\/\/\n\/\/ GET: \/Product\/\n\npublic ActionResult Index()\n{\n    ProductRepository productRepository = new ProductRepository();\n\n    return View(productRepository.Select().ToList());\n}\n<\/pre>\n<pre>&nbsp;<\/pre>\n<\/div>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p>Now, we create the view to display this data. Locate the <em>Views <\/em>folder that was created by the ASP.NET MVC project template and add a subfolder with the name Product. Notice that this folder\u2019s name matches that of the prefix of our controller. This is by design. ASP.NET MVC provides this convention to make our lives a bit easier (<a href=\"http:\/\/en.wikipedia.org\/wiki\/Convention_over_Configuration\" target=\"_blank\" rel=\"noopener\">CoC<\/a>). The ASP.NET MVC framework will first look for the subfolder that matches your controller. If it is not found, it will then look in the Shared subfolder. Now, right-click the <em>Product<\/em> folder and select <em>Add-&gt;View\u2026 <\/em>Enter the view name Index, select to create a strongly-typed view, select the appropriate data model class, and select <em>List<\/em> from the view content drop down.<\/p>\n<p>&nbsp;<a href=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmpb031.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"tmpB031\" border=\"0\" alt=\"tmpB031\" src=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmpb031-thumb.png\" width=\"386\" height=\"410\"><\/a><\/p>\n<p>Take a look a the newly created View. There is code already generated for viewing a list of our object. This is convenient, but we are going to modify it slightly to display the data in a more meaningful manner.<\/p>\n<pre class=\"brush: xml;\">&lt;% foreach (var item in Model) { %&gt;\n\n  &lt;tr&gt;\n      &lt;td&gt;\n          &lt;%= Html.ActionLink(\"Edit\", \"Edit\", new { id=item.id }) %&gt; |\n          &lt;%= Html.ActionLink(\"Details\", \"Details\", new { id=item.id })%&gt;\n      &lt;\/td&gt;\n      &lt;td&gt;\n          &lt;%= Html.Encode(item.Category.name) %&gt;\n      &lt;\/td&gt;\n      &lt;td&gt;\n          &lt;%= Html.Encode(item.id) %&gt;\n      &lt;\/td&gt;\n      &lt;td&gt;\n          &lt;%= Html.Encode(item.name) %&gt;\n      &lt;\/td&gt;\n  &lt;\/tr&gt;\n\n&lt;% } %&gt;\n<\/pre>\n<div class=\"csharpcode\">&nbsp;<\/div>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p>Notice that we are accessing the Category property of the Product object. This was made possible by extending the Product partial class to include this property. When we run this we should see a listing of our products. (Note: Database backup with test data is included with source download.)<\/p>\n<p><a href=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmp98bc.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"tmp98BC\" border=\"0\" alt=\"tmp98BC\" src=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmp98bc-thumb.png\" width=\"408\" height=\"305\"><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>Adding and Editing data<\/strong><\/p>\n<p>For the case of adding and editing our data, we are going to add two controller methods. The first will process the http GET command and return the View used for adding or editing our data. The second will process the http POST command. This overloaded method will be marked with a special attribute to designate that it is responsible for handling POSTs for this action. So for adding data we must specify our Create methods.<\/p>\n<div class=\"csharpcode\">\n<pre class=\"brush: csharp;\">\/\/\n\/\/ GET: \/Product\/Create\n\npublic ActionResult Create()\n{\n   return View();\n} \n\n\/\/\n\/\/ POST: \/Product\/Create\n\n[AcceptVerbs(HttpVerbs.Post)]\npublic ActionResult Create(FormCollection formCollection)\n{\n  try\n  {\n      Product product = new Product();\n      TryUpdateModel(product);\n\n      var productRepo = new ProductRepository();\n      productRepo.Add(product);\n      productRepo.Save();\n\n      return RedirectToAction(\"Index\");\n  }\n  catch\n  {\n       return View();\n  }\n}\n<\/pre>\n<pre>&nbsp;<\/pre>\n<\/div>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p>And for editing our data will provide Edit methods.<\/p>\n<div class=\"csharpcode\">\n<pre class=\"brush: csharp;\">public ActionResult Edit(int id)\n{           \n  var productRepo = new ProductRepository();\n  var product = productRepo.Select(id);\n\n  return View(product);\n}\n\n\/\/\n\/\/ POST: \/Product\/Edit\/5\n\n[AcceptVerbs(HttpVerbs.Post)]\npublic ActionResult Edit(int id, FormCollection collection)\n{\n  try\n  {\n      var productRepo = new ProductRepository();\n      var product = productRepo.Select(id);\n\n      TryUpdateModel(product);\n\n      productRepo.Save();\n\n      return RedirectToAction(\"Index\");\n  }\n  catch\n  {\n      return View();\n  }\n}\n<\/pre>\n<pre>&nbsp;<\/pre>\n<\/div>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p>Notice that the Edit implementation responsible for handling GETs differs from our Create GET implementation. It must fetch the item that we will be editing and hand it off to the view. There is one more step before we are ready to create our Views. For the sake of user friendliness we are going to provide a drop down list to allow the user to select the category by name instead of requiring them to input a Category id. To accomplish this we must fetch the collection of Categories and make it available to the View. For simplicities sake, we will do this in the Controller\u2019s constructor.<\/p>\n<div class=\"csharpcode\">\n<pre>&nbsp;<\/pre>\n<pre class=\"brush: csharp;\">public ProductController() : base()\n{\n      var categoryRepo = new CategoryRepository();\n      ViewData[\"categories\"] = categoryRepo.Select().ToList();\n}\n<\/pre>\n<pre>&nbsp;<\/pre>\n<\/div>\n<p>Now we are ready create our Views. Just like with the Create View we will right-click on the Product subfolder in the View folder and select Add-&gt;View\u2026<\/p>\n<p><a href=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmpe357.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"tmpE357\" border=\"0\" alt=\"tmpE357\" src=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmpe357-thumb.png\" width=\"364\" height=\"380\"><\/a><\/p>\n<p><a href=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmp8928.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"tmp8928\" border=\"0\" alt=\"tmp8928\" src=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmp8928-thumb.png\" width=\"366\" height=\"387\"><\/a><\/p>\n<p>Again, we will edit the generated code for the Views to enhance the user experience.<\/p>\n<div class=\"csharpcode\">\n<pre class=\"brush: xml;\"> &lt;% using (Html.BeginForm()) {%&gt;\n\n     &lt;fieldset&gt;\n         &lt;legend&gt;Fields&lt;\/legend&gt;\n         &lt;p&gt;\n              &lt;label for=\"Category\"&gt;Category:&lt;\/label&gt;\n             &lt;%= Html.DropDownList(\"categoryid\", new SelectList((IEnumerable)ViewData[\"categories\"], \"id\", \"name\")) %&gt;\n             &lt;%= Html.ValidationMessage(\"categoryid\", \"*\") %&gt;\n         &lt;\/p&gt;\n        &lt;p&gt;\n            &lt;label for=\"name\"&gt;Name:&lt;\/label&gt;\n            &lt;%= Html.TextBox(\"name\") %&gt;\n            &lt;%= Html.ValidationMessage(\"name\", \"*\") %&gt;\n        &lt;\/p&gt;\n        &lt;p&gt;\n            &lt;input type=\"submit\" value=\"Create\" \/&gt;\n        &lt;\/p&gt;\n    &lt;\/fieldset&gt;\n\n&lt;% } %&gt;\n\n<\/pre>\n<pre>&nbsp;<\/pre>\n<\/div>\n<style type=\"text\/css\">\n<p>.csharpcode, .csharpcode pre\n{\n\tfont-size: small;\n\tcolor: black;\n\tfont-family: consolas, \"Courier New\", courier, monospace;\n\tbackground-color: #ffffff;\n\t\/*white-space: pre;*\/\n}\n.csharpcode pre { margin: 0em; }\n.csharpcode .rem { color: #008000; }\n.csharpcode .kwrd { color: #0000ff; }\n.csharpcode .str { color: #006080; }\n.csharpcode .op { color: #0000c0; }\n.csharpcode .preproc { color: #cc6633; }\n.csharpcode .asp { background-color: #ffff00; }\n.csharpcode .html { color: #800000; }\n.csharpcode .attr { color: #ff0000; }\n.csharpcode .alt \n{\n\tbackground-color: #f4f4f4;\n\twidth: 100%;\n\tmargin: 0em;\n}\n.csharpcode .lnum { color: #606060; }<\/style>\n<p>And\u2026<\/p>\n<pre class=\"brush: xml;\">&lt;% using (Html.BeginForm()) {%&gt;\n\n     &lt;fieldset&gt;\n         &lt;legend&gt;Fields&lt;\/legend&gt;\n         &lt;p&gt;\n             &lt;label for=\"id\"&gt;ID:&lt;\/label&gt;\n             &lt;%= Html.Encode(Model.id) %&gt;\n             \n         &lt;\/p&gt;\n        &lt;p&gt;\n            &lt;label for=\"category\"&gt;Category:&lt;\/label&gt;\n            &lt;%= Html.DropDownList(\"categoryid\", new SelectList((IEnumerable)ViewData[\"categories\"], \"id\", \"name\")) %&gt;\n            &lt;%= Html.ValidationMessage(\"categoryid\", \"*\") %&gt;\n        &lt;\/p&gt;\n        &lt;p&gt;\n            &lt;label for=\"name\"&gt;Name:&lt;\/label&gt;\n            &lt;%= Html.TextBox(\"name\", Model.name) %&gt;\n            &lt;%= Html.ValidationMessage(\"name\", \"*\") %&gt;\n        &lt;\/p&gt;\n        &lt;p&gt;\n            &lt;input type=\"submit\" value=\"Save\" \/&gt;\n        &lt;\/p&gt;\n    &lt;\/fieldset&gt;\n\n&lt;% } %&gt;\n\n<\/pre>\n<p>This will produce pages that allow the user to easily create and edit data.<\/p>\n<p><a href=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmp5c11.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px\" title=\"tmp5C11\" border=\"0\" alt=\"tmp5C11\" src=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmp5c11-thumb.png\" width=\"393\" height=\"382\"><\/a><\/p>\n<p>That\u2019s it. Now you are ready to rock with MySQL, Entity Framework, and ASP.NET MVC!<\/p>\n<p><strong>What about our test project?<\/strong><\/p>\n<p>Remember in <a href=\"http:\/\/pattersoncprod.wpengine.com\/index.php\/2009\/04\/01\/using-mysql-with-entity-framework-and-aspnet-mvc-%e2%80%93-part-i\/\" target=\"_blank\" rel=\"noopener\">Part I<\/a> when I asked you to create a test project along with our ASP.NET MVC application? I have decided to leave unit tests out of this series for the sake of simplicity and the fact that Visual Studio Test Projects are only supported in the Professional version of Visual Studio. In a future post I will cover writing unit tests for ASP.NET MVC projects using an open source unit test framework like nUnit or mbUnit. At that time, I will attempt to demonstrate developing our sample project following a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Test-driven_development\" target=\"_blank\" rel=\"noopener\">Test Driven Development<\/a> technique.<\/p>\n<p><strong>Summary<\/strong><\/p>\n<p>We were able to easily to generate a data model for a MySQL database schema using Entity Framework.<\/p>\n<p>We were able to access our data model from an ASP.NET MVC project. We created strongly typed Views that allowed us dictate exactly how we wanted our pages to render for simple CRUD scenarios.<\/p>\n<p>For more advanced scenarios using ASP.NET MVC, such as adding validation to your data model and securing your application, check out the free <a href=\"http:\/\/weblogs.asp.net\/scottgu\/archive\/2009\/03\/10\/free-asp-net-mvc-ebook-tutorial.aspx\" target=\"_blank\" rel=\"noopener\">NerdDinner ASP.NET MVC Tutorial<\/a>.<\/p>\n<p>&nbsp;<\/p>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:FF7EC618-8FBE-49a5-B908-2339AF2ABCDF:674012e8-ec69-4509-94a1-d2aab7797383\" class=\"wlWriterSmartContent\">\n<div>Download File &#8211; <a href=\"https:\/\/pattersonc.com\/wp-content\/uploads\/2009\/04\/tmp5669.zip\" target=\"_self\" rel=\"noopener\">Source<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>I am going to wrap up this two part series on using MySQL with Entity Framework. Below is a link to the initial installment. Using MySQL with Entity Framework and ASP.NET MVC \u2013 Part I In Part I, we created a database schema in MySQL, generated a data model using Entity Framework, and wrapped the &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_block_theme_hide_title":false,"footnotes":""},"categories":[3],"tags":[2,4,5],"class_list":{"0":"post-72","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-code","7":"tag-aspnet-mvc","8":"tag-entity-framework","9":"tag-mysql","11":"without-featured-image"},"featured_image_src":null,"featured_image_src_square":null,"author_info":{"display_name":"Christopher Patterson","author_link":"https:\/\/pattersonc.com\/?author=1"},"_links":{"self":[{"href":"https:\/\/pattersonc.com\/index.php?rest_route=\/wp\/v2\/posts\/72","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pattersonc.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pattersonc.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pattersonc.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pattersonc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=72"}],"version-history":[{"count":0,"href":"https:\/\/pattersonc.com\/index.php?rest_route=\/wp\/v2\/posts\/72\/revisions"}],"wp:attachment":[{"href":"https:\/\/pattersonc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pattersonc.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pattersonc.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}