{"id":10991,"date":"2021-10-17T19:07:50","date_gmt":"2021-10-17T10:07:50","guid":{"rendered":"http:\/\/www.webcyou.com\/?p=10991"},"modified":"2021-10-17T19:07:50","modified_gmt":"2021-10-17T10:07:50","slug":"%e3%80%90m1-mac%e3%80%91dotnet-ef-%e3%83%84%e3%83%bc%e3%83%ab%e3%81%a7%e3%80%81mysql%e3%82%92-scaffold%e3%81%99%e3%82%8b%e3%80%82","status":"publish","type":"post","link":"https:\/\/www.webcyou.com\/?p=10991","title":{"rendered":"\u3010M1 Mac\u3011dotnet ef \u30c4\u30fc\u30eb\u3067\u3001MySQL\u3092 scaffold\u3059\u308b\u3002"},"content":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002<\/p>\n<p>\u6700\u8fd1\u3082\u3063\u3071\u3089C#\u3092\u66f8\u3044\u3066\u3044\u308b\u65e5\u3005\u3067\u3059\u3002<\/p>\n<p>\u306a\u305c\u304b\u3068\u8a00\u3046\u3068\u9577\u3044\u306e\u3067\u5272\u611b\u3055\u305b\u3066\u9802\u304d\u307e\u3059\u304c\u3001\u3056\u3063\u3068\u8aac\u660e\u3059\u308b\u3068\u3001Web\u306e\u672a\u6765\u306e\u4e00\u3064\u3068\u3057\u3066Webassembly\u306e\u6280\u8853\u304c\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u305d\u306eWebassembly\u3092\u7528\u3044\u3066\u3001Unity\u3068Web\u306e\u9023\u643a\u3092\u8272\u3005\u3068\u6a21\u7d22\u3057\u306a\u304c\u3089\u884c\u3063\u3066\u3044\u308b\u3046\u3061\u306b\u3001Unity\u3084\u3089Blazor\u3084\u3089\u3092\u6271\u3063\u3066\u3044\u308b\u8a33\u3067\u3059\u3002<\/p>\n<p>\u3067\u3001\u3053\u3061\u3089\u306eBlazor\u306e\u66f8\u7c4d\u3092\u9032\u3081\u3066\u3044\u305f\u3068\u3053\u308d\u3076\u3064\u304b\u3063\u305f\u306e\u304c\u3001\u300c\u7b2c9\u7ae0 \u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u30a2\u30af\u30bb\u30b9\u300d\u306e\u7ae0\u3002<\/p>\n<div id=\"rinkerid10990\" class=\"yyi-rinker-contents  yyi-rinker-tagid-246 yyi-rinker-postid-10990 yyi-rinker-img-m yyi-rinker-catid-273 \">\n\t<div class=\"yyi-rinker-box\">\n\t\t<div class=\"yyi-rinker-image\">\n\t\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/B08QM7QJB1?tag=panicdragon-22&#038;linkCode=ogi&#038;th=1&#038;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-tracking\"  data-click-tracking=\"amazon_img 10990 Blazor\u5165\u9580\" data-vars-click-id=\"amazon_img 10990 Blazor\u5165\u9580\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/m.media-amazon.com\/images\/I\/41wCab1yFGL._SL160_.jpg\"  width=\"124\" height=\"160\" class=\"yyi-rinker-main-img\" style=\"border: none;\"><\/a>\t\t\t\t\t<\/div>\n\t\t<div class=\"yyi-rinker-info\">\n\t\t\t<div class=\"yyi-rinker-title\">\n\t\t\t\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/B08QM7QJB1?tag=panicdragon-22&#038;linkCode=ogi&#038;th=1&#038;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-tracking\" data-click-tracking=\"amazon_title 10990 Blazor\u5165\u9580\" data-vars-amp-click-id=\"amazon_title 10990 Blazor\u5165\u9580\" >Blazor\u5165\u9580<\/a>\t\t\t\t\t\t\t<\/div>\n\t\t\t<div class=\"yyi-rinker-detail\">\n\t\t\t\t\t\t\t<div class=\"credit-box\">created by&nbsp;<a href=\"https:\/\/oyakosodate.com\/rinker\/\" rel=\"nofollow noopener\" target=\"_blank\" >Rinker<\/a><\/div>\n\t\t\t\t\t\t\t\t\t\t<div class=\"price-box\">\n\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t\t<ul class=\"yyi-rinker-links\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"amazonkindlelink\">\n\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/B08QM7QJB1?tag=panicdragon-22&amp;linkCode=ogi&amp;th=1&amp;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"amazon_kindle 10990 Blazor\u5165\u9580\"  data-vars-amp-click-id=\"amazon_kindle 10990 Blazor\u5165\u9580\">Kindle<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t                    <li class=\"amazonlink\">\n\t\t\t\t\t\t<a href=\"https:\/\/www.amazon.co.jp\/dp\/B08QM7QJB1?tag=panicdragon-22&amp;linkCode=ogi&amp;th=1&amp;psc=1\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"amazon 10990 Blazor\u5165\u9580\"  data-vars-amp-click-id=\"amazon 10990 Blazor\u5165\u9580\">Amazon<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"rakutenlink\">\n\t\t\t\t\t\t<a href=\"https:\/\/hb.afl.rakuten.co.jp\/hgc\/2cd584c0.7789074a.2cd584c1.9c3f8e52\/Rinker_o_20211017174445?pc=https%3A%2F%2Fsearch.rakuten.co.jp%2Fsearch%2Fmall%2FBlazor%25E5%2585%25A5%25E9%2596%2580%2F%3Ff%3D1%26grp%3Dproduct&amp;m=https%3A%2F%2Fsearch.rakuten.co.jp%2Fsearch%2Fmall%2FBlazor%25E5%2585%25A5%25E9%2596%2580%2F%3Ff%3D1%26grp%3Dproduct\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"rakuten 10990 Blazor\u5165\u9580\"  data-vars-amp-click-id=\"rakuten 10990 Blazor\u5165\u9580\">\u697d\u5929\u5e02\u5834<\/a>\t\t\t\t\t<\/li>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<li class=\"yahoolink\">\n\t\t\t\t\t\t<a href=\"https:\/\/ck.jp.ap.valuecommerce.com\/servlet\/referral?sid=3670338&amp;pid=888118650&amp;vc_url=https%3A%2F%2Fshopping.yahoo.co.jp%2Fsearch%3Fp%3DBlazor%25E5%2585%25A5%25E9%2596%2580\" rel=\"nofollow\" class=\"yyi-rinker-link yyi-rinker-tracking\"  data-click-tracking=\"yahoo 10990 Blazor\u5165\u9580\"  data-vars-amp-click-id=\"yahoo 10990 Blazor\u5165\u9580\">Yahoo\u30b7\u30e7\u30c3\u30d4\u30f3\u30b0<\/a><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ad.jp.ap.valuecommerce.com\/servlet\/gifbanner?sid=3670338&pid=888118650\" height=\"1\" width=\"1\" border=\"0\">\t\t\t\t\t<\/li>\n\t\t\t\t                \t\t\t\t\t\t\t\t\t\t\t<\/ul>\n\t\t\t\t\t<\/div>\n\t<\/div>\n<\/div>\n\n<p>9.2 SQLSever\u306e\u5229\u7528\u3067\u3001\u305a\u3063\u3068MySQL\u3068\u601d\u3063\u3066\u9032\u3081\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u5168\u7136\u3046\u307e\u304f\u3044\u304b\u305a\u3002\u3002<\/p>\n<p>\u3088\u304f\u3088\u304f\u898b\u308b\u3068\u3001\u300c<strong>Microsoft SQL Server<\/strong>\u300d\u3063\u3066\u3044\u3046\u306e\u304c\u3042\u3063\u3066\u3001\u305d\u308c\u3067\u306f\u306a\u3044\u304bw<\/p>\n<p>\u305d\u3046\u3044\u3046\u306e\u304c\u3042\u308b\u306e\u304b\u3002\u3002\uff08Microsoft\u306e\u30a8\u30b3\u30b7\u30b9\u30c6\u30e0\u306b\u3042\u307e\u308a\u89e6\u308c\u3066\u3044\u306a\u3044\u306e\u3067\u3002\u3002\uff09<\/p>\n<p>Parallels Desktop\uff08Arm windows\uff09\u306eVisual Studio\u3067\u3084\u308a\u76f4\u3059\u3068\u3001\u3059\u3093\u306a\u308a\u3044\u304d\u307e\u3057\u305f\u3002<\/p>\n<p>\u3067\u3001\u672c\u984c\u306a\u306e\u3067\u3059\u304c\u3001<strong>M1 Mac\uff08Intel Mac\u3082\u540c\u69d8\uff09\u3067\u958b\u767a\u9032\u3081\u305f\u3044\u4e0a\u306b\u3001dotnet ef \u30c4\u30fc\u30eb\u3067\u300cMySQL\u300d\u3092scaffold<\/strong>\u3057\u305f\u3044\u3002<\/p>\n<p>\u3068\u8a00\u3063\u305f\u3068\u3053\u308d\u3067\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u672c\u66f8\u3067\u306f\u3001MySQL\u306escaffold\u306f\u3067\u304d\u306a\u3044\u3068\u8a18\u8f09\u3055\u308c\u3066\u3044\u307e\u3057\u305f\u304c\u3001\u8abf\u3079\u308b\u3068\u3067\u304d\u305d\u3046\u3067\u3001\u3084\u3063\u3066\u307f\u305f\u3068\u3053\u308d\u6210\u529f\u3057\u307e\u3057\u305f\u306e\u3067\u3001\u305d\u306e\u30ed\u30b0\u3067\u3082\u3068\u3002<\/p>\n<p>\u30d9\u30fc\u30b9\u306f\u3001MySQL\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306e <a href=\"https:\/\/dev.mysql.com\/doc\/connector-net\/en\/connector-net-entityframework-core-scaffold-example.html#connector-net-entityframework-core-scaffold-cli\">7.2.2 Scaffolding an Existing Database in EF Core<\/a> \u3092\u53c2\u8003\u306b\u3057\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u306e\u307e\u307e\u3060\u3068\u5931\u6557\u3057\u3066\u3044\u305f\u306e\u3067\u3001\u30d0\u30fc\u30b8\u30e7\u30f3\u3092\u5909\u66f4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<h4>MySQL\u30c7\u30fc\u30bf\u6e96\u5099<\/h4>\n<p>MySQL\u306e\u30c7\u30fc\u30bf\u3092\u6e96\u5099\u3057\u307e\u3059\u3002\u3053\u3061\u3089\u3082\u8a73\u7d30\u306f\u5272\u611b\u3055\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3059\u3002<\/p>\n<p>\u4e0a\u8a18\u306e\u30b5\u30f3\u30d7\u30eb\u30c7\u30fc\u30bf\u306e\u3088\u3046\u306b\u3001\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u306f\u300cblazordb\u300d\u3001\u30c6\u30fc\u30d6\u30eb\u306f\u300cbooks\u300d\u3067\u4f5c\u6210\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10992\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef1.png\" alt=\"\" width=\"511\" height=\"107\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef1.png 511w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef1-300x63.png 300w\" sizes=\"auto, (max-width: 511px) 100vw, 511px\" \/><\/p>\n<p>\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u540d\u3001\u30c6\u30fc\u30d6\u30eb\u540d\u306a\u3069MySQL\u5074\u306e\u8a2d\u5b9a\u3084\u30c7\u30fc\u30bf\u306f\u4efb\u610f\u3067\u304a\u9858\u3044\u3057\u307e\u3059\u3002<\/p>\n<h4>.NET Core CLI\u3092\u7528\u3044\u3066MySQL\u3092Scaffolding<\/h4>\n<p>\u307e\u305a\u306f\u3068\u3082\u3042\u308c\u3001dotnet\u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u7528\u3067\u304d\u308b\u72b6\u614b\u306b\u3057\u307e\u3059\u3002<br \/>\ndotnet ef\u30c4\u30fc\u30eb\u3092\u4f7f\u7528\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dotnet ef<\/pre>\n<p>\u4e0a\u8a18\u306e\u30b3\u30de\u30f3\u30c9\u3067\u4ee5\u4e0b\u306e\u8868\u793a\u306b\u306a\u308c\u3070\u30c4\u30fc\u30eb\u306f\u4f7f\u7528\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10993\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef2.png\" alt=\"\" width=\"499\" height=\"392\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef2.png 499w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef2-300x236.png 300w\" sizes=\"auto, (max-width: 499px) 100vw, 499px\" \/><\/p>\n<p>\u8868\u793a\u3057\u306a\u3051\u308c\u3070\u3001dotnet ef\u3092\u30b0\u30ed\u30fc\u30d0\u30eb\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dotnet tool install \u2014global dotnet-ef<\/pre>\n<p>\u3068\u308a\u3042\u3048\u305a\u3001MySQL\u3092Scaffolding\u3057\u305f\u3044\u3060\u3051\u306a\u306e\u3067\u3001\u5c0f\u3055\u304f .NET Core command-line interface (CLI)\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u3068\u3057\u3066\u958b\u59cb\u3057\u307e\u3059\u3002<br \/>\n\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u304c\u4f5c\u6210\u3055\u308c\u305f\u3089\u305d\u3061\u3089\u306b\u79fb\u52d5\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dotnet new console -o sakilaConsole\r\n$ cd sakilaConsole<\/pre>\n<p>\u7d9a\u3044\u3066\u3001EF\u30b3\u30a2\u7528\u306e MySQL NuGet \u30d1\u30c3\u30b1\u30fc\u30b8\u3067\u3042\u308b\u300cMySql.EntityFrameworkCore\u300d\u3092\u8ffd\u52a0\u3057\u307e\u3059\u3002<br \/>\n\u3053\u3053\u3067\u3001\u516c\u5f0f\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u8a18\u8f09\u3057\u3066\u3044\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u3060\u3068\u30e1\u30bd\u30c3\u30c9\u304c\u306a\u3044\u305e\u3002\u3068\u30a8\u30e9\u30fc\u5410\u3044\u3066\u3044\u307e\u3057\u305f\u306e\u3067\u3001\u7279\u306b\u30d0\u30fc\u30b8\u30e7\u30f3\u6307\u5b9a\u305b\u305a\u3001\u6700\u65b0\u3092\u5165\u308c\u308b\u3053\u3068\u306b\u3088\u3063\u3066\u3001\u30a8\u30e9\u30fc\u304c\u56de\u907f\u3055\u308c\u307e\u3057\u305f\u3002<\/p>\n<p>\u300c<strong>MySql.EntityFrameworkCore<\/strong>\u300d\u300c<strong>MySql.Data.EntityFrameworkCore<\/strong>\u300d\u300c<strong>Microsoft.EntityFrameworkCore.Tools<\/strong>\u300d\u3092\u305d\u308c\u305e\u308c\u8ffd\u52a0\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dotnet add package MySql.EntityFrameworkCore\r\n$ dotnet add package MySql.Data.EntityFrameworkCore\r\n$ dotnet add package Microsoft.EntityFrameworkCore.Tools<\/pre>\n<p>\u300cdotnet restore\u300d\u30b3\u30de\u30f3\u30c9\u3067\u3001\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u30d5\u30a1\u30a4\u30eb\u3067\u6307\u5b9a\u3055\u308c\u3066\u3044\u308b\u4f9d\u5b58\u95a2\u4fc2\u3084\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u56fa\u6709\u306e\u30c4\u30fc\u30eb\u3092\u5fa9\u5143\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dotnet restore<\/pre>\n<h4>MySQL\u63a5\u7d9a\u6587<\/h4>\n<p>dotnet ef\u30c4\u30fc\u30eb\u3067\u3001MySQL\u3092Scaffolding\u3059\u308b\u70ba\u306b\u3001\u5fc5\u8981\u306aNuGet \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u8ffd\u52a0\u3057\u307e\u3057\u305f\u306e\u3067\u3001dotnet ef\u3067\u5b9f\u969b\u306b\u884c\u3063\u3066\u3044\u304d\u307e\u3059\u3002<br \/>\nScaffolding\u3059\u308b\u70ba\u306b\u5fc5\u8981\u306a\u30b3\u30de\u30f3\u30c9\u306f<a href=\"https:\/\/dev.mysql.com\/doc\/connector-net\/en\/connector-net-entityframework-core-scaffold-example.html#connector-net-entityframework-core-scaffold-filter\">MySQL\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u8a18\u8f09<\/a>\u3055\u308c\u3066\u3044\u308b\u4ee5\u4e0b\u306e\u3068\u304a\u308a\u3068\u306a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dotnet ef dbcontext scaffold \"connection-string\" MySql.EntityFrameworkCore -o sakila -f<\/pre>\n<p>\u3053\u3053\u3067\u3001\u8a18\u8f09\u3055\u308c\u3066\u3044\u308b\u300c&#8221;connection-string&#8221;\u300d\u7b87\u6240\u306b\u3001MySQL\u63a5\u7d9a\u6587\u5b57\u5217\u304c\u306f\u3044\u308b\u306e\u3067\u3059\u304c\u3001<a href=\"https:\/\/dev.mysql.com\/doc\/connector-net\/en\/connector-net-connections-string.html\">MySQL\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3067\u306e\u63a5\u7d9a\u6587\u5b57\u5217<\/a>\u306e\u30b5\u30f3\u30d7\u30eb\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\"server=127.0.0.1;uid=root;pwd=12345;database=test\"<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b\u3001MySQL\u63a5\u7d9a\u6587\u5b57\u5217\u3092\u6307\u5b9a\u3059\u308b\u306e\u3067\u3001\u304a\u4f7f\u3044\u306e\u74b0\u5883\u306b\u5408\u308f\u305b\u3066\u5909\u66f4\u3057\u307e\u3059\u3002<br \/>\n\u300clocalhost\u300d\u306e\u6587\u5b57\u5217\u3067\u3082\u554f\u984c\u306a\u304b\u3063\u305f\u3057\u3001\u4ed6\u306e\u30b5\u30a4\u30c8\u306e\u4f8b\u3092\u307f\u3066\u307f\u308b\u3068\u300cServer\u300d\u306a\u3069\u982d\u304c\u5927\u6587\u5b57\u3001\u300cUserId\u300d\u306a\u3069\u6587\u5b57\u5217\u304c\u7570\u306a\u308b\u6307\u5b9a\u306e\u4f8b\u304c\u66f8\u304b\u308c\u3066\u3044\u307e\u3059\u304c\u3001\u305d\u3061\u3089\u3067\u3082\u5b9f\u884c\u3067\u304d\u305f\u306e\u3067\u3001\u3042\u308b\u7a0b\u5ea6\u30d0\u30ea\u30a8\u30fc\u30b7\u30e7\u30f3\u304c\u5b58\u5728\u3057\u3066\u3044\u308b\u3088\u3046\u3067\u3059\u3002<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">$ dotnet ef dbcontext scaffold \"server=localhost;database=blazordb;uid=root;password=\" MySql.EntityFrameworkCore -o sakila -f<\/pre>\n<p>\u5b9f\u884c\u3057\u3001<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">Build started...\r\nBuild succeeded.<\/pre>\n<p>\u3068\u8868\u793a\u3057\u3001\u30a8\u30e9\u30fc\u304c\u306a\u3051\u308c\u3070\u3001Scaffolding\u3055\u308c\u305f\u30e2\u30c7\u30eb\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u304c\u751f\u6210\u3055\u308c\u307e\u3059\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-10994\" src=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef3.png\" alt=\"\" width=\"384\" height=\"124\" srcset=\"https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef3.png 384w, https:\/\/www.webcyou.com\/wp-content\/uploads\/2021\/10\/dotnet-ef3-300x97.png 300w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/p>\n<p>\u4e2d\u8eab\u3092\u78ba\u8a8d\u3059\u308b\u3068\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306bEntity\u30af\u30e9\u30b9\u30d5\u30a1\u30a4\u30eb\u306e\u751f\u6210\u3084\u3001<\/p>\n<p><strong>Book.cs<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">using System;\r\nusing System.Collections.Generic;\r\n\r\n#nullable disable\r\n\r\nnamespace sakilaConsole.sakila\r\n{\r\n    public partial class Book\r\n    {\r\n        public int Id { get; set; }\r\n        public string Title { get; set; }\r\n        public string Author { get; set; }\r\n        public int Price { get; set; }\r\n        public string Publisher { get; set; }\r\n    }\r\n}<\/pre>\n<p>\u30c7\u30fc\u30bf\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb\u306e\u751f\u6210\u304c\u6210\u529f\u3055\u308c\u3066\u3044\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><strong>blazordbContext.cs<\/strong><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">using System;\r\nusing Microsoft.EntityFrameworkCore;\r\nusing Microsoft.EntityFrameworkCore.Metadata;\r\n\r\n#nullable disable\r\n\r\nnamespace sakilaConsole.sakila\r\n{\r\n    public partial class blazordbContext : DbContext\r\n    {\r\n        public blazordbContext()\r\n        {\r\n        }\r\n\r\n        public blazordbContext(DbContextOptions&lt;blazordbContext&gt; options)\r\n            : base(options)\r\n        {\r\n        }\r\n\r\n        public virtual DbSet&lt;Book&gt; Books { get; set; }\r\n\r\n        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)\r\n        {\r\n            if (!optionsBuilder.IsConfigured)\r\n            {\r\n#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https:\/\/go.microsoft.com\/fwlink\/?linkid=2131148. For more guidance on storing connection strings, see http:\/\/go.microsoft.com\/fwlink\/?LinkId=723263.\r\n                optionsBuilder.UseMySQL(&quot;server=localhost;database=blazordb;uid=root;password=&quot;);\r\n            }\r\n        }\r\n\r\n        protected override void OnModelCreating(ModelBuilder modelBuilder)\r\n        {\r\n            modelBuilder.Entity&lt;Book&gt;(entity =&gt;\r\n            {\r\n                entity.ToTable(&quot;books&quot;);\r\n\r\n                entity.Property(e =&gt; e.Id)\r\n                    .HasColumnType(&quot;int unsigned&quot;)\r\n                    .HasColumnName(&quot;id&quot;);\r\n\r\n                entity.Property(e =&gt; e.Author)\r\n                    .IsRequired()\r\n                    .HasMaxLength(50)\r\n                    .HasColumnName(&quot;author&quot;)\r\n                    .HasDefaultValueSql(&quot;''&quot;);\r\n\r\n                entity.Property(e =&gt; e.Price).HasColumnName(&quot;price&quot;);\r\n\r\n                entity.Property(e =&gt; e.Publisher)\r\n                    .HasMaxLength(50)\r\n                    .HasColumnName(&quot;publisher&quot;);\r\n\r\n                entity.Property(e =&gt; e.Title)\r\n                    .IsRequired()\r\n                    .HasMaxLength(50)\r\n                    .HasColumnName(&quot;title&quot;)\r\n                    .HasDefaultValueSql(&quot;''&quot;);\r\n            });\r\n\r\n            OnModelCreatingPartial(modelBuilder);\r\n        }\r\n\r\n        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);\r\n    }\r\n}<\/pre>\n<p>M1 Mac\u3067\u3082\u4e0a\u8a18\u306e\u3088\u3046\u306b\u3001dotnet ef\u30c4\u30fc\u30eb\u306b\u3088\u308bMySQL\u306escaffold\u304c\u884c\u3048\u308b\u306e\u304c\u78ba\u8a8d\u3067\u304d\u3066\u3088\u304b\u3063\u305f\u3067\u3059\u3002<br \/>\nVisual Studio\u306e\u3084\u308a\u65b9\u3082\u307b\u307c\u540c\u69d8\u3067\u3059\u304c\u3001\u624b\u9806\u306a\u3069\u3082\u8ffd\u3063\u3066\u8a18\u8f09\u3067\u304d\u308c\u3070\u3068\u601d\u3063\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<p>\u3067\u306f\u3067\u306f\u3001\u307e\u305f\u307e\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3069\u3082\u3067\u3059\u3002 \u6700\u8fd1\u3082\u3063\u3071\u3089C#\u3092\u66f8\u3044\u3066\u3044\u308b\u65e5\u3005\u3067\u3059\u3002 \u306a\u305c\u304b\u3068\u8a00\u3046\u3068\u9577\u3044\u306e\u3067\u5272\u611b\u3055\u305b\u3066\u9802\u304d\u307e\u3059\u304c\u3001\u3056\u3063\u3068\u8aac\u660e\u3059\u308b\u3068\u3001Web\u306e\u672a\u6765\u306e\u4e00\u3064\u3068\u3057\u3066Webassembly\u306e\u6280\u8853\u304c\u3042\u308b\u304b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u305d\u306eWebassembly\u3092\u7528\u3044 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[273],"tags":[176,46,44,45,39,55,178,78,114,118],"class_list":{"0":"post-10991","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"hentry","6":"category-c-3","7":"tag-html5","8":"tag-js","9":"tag-web","11":"tag-39","12":"tag-55","13":"tag-178","14":"tag-78","15":"tag-114","16":"tag-118"},"_links":{"self":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10991","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10991"}],"version-history":[{"count":3,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10991\/revisions"}],"predecessor-version":[{"id":10997,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=\/wp\/v2\/posts\/10991\/revisions\/10997"}],"wp:attachment":[{"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcyou.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}