c 自动生成mysql表结构_EntityFrameworkCore 根据实体类自动创建数据库

1.首先新建 Asp.Net Core WebApi 项目

d832b2d0e18abbf2bed7451c146e4c1c.png

2.添加一下引用 :

2.1   Pomelo.EntityFrameworkCore.MySql(我用的Mysql 根据自己情况引用就行)

2.2  Microsoft.EntityFrameworkCore

2.3 Microsoft.EntityFrameworkCore.Design

7fca7106b5ffd8d9e0e28c4a4590d2b1.png

3.使项目支持dotnet ef 工具以使用Migrations

3.1 手动修改csproj文件(手动添加是因为在nuget添加Microsoft.EntityFrameworkCore.Tools.DotNet 时报错,估计是vs的问题),添加一下配置

fa07d1b0d6fc472f78ce6f049a80146f.png

4.打开CMD命令 cd到项目目录下(C:\Users\Administrator\source\repos\CodeFirst\CodeFirst),执行

dotnet build

Microsoft (R) Build Engine version 15.1.545.13942 Copyright (C) Microsoft Corporation. All rights reserved. Startup.cs(45,13): warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. [C:\WorkSpacesC\DotNetCore\EntityFrameworkCoreMigrationsDemo\EntityFrameworkCoreMigrationsDemo\EntityFrameworkCoreMigrationsDemo.csproj] EntityFrameworkCoreMigrationsDemo -> C:\WorkSpacesC\DotNetCore\EntityFrameworkCoreMigrationsDemo\EntityFrameworkCoreMigrationsDemo\bin\Debug\netcoreapp1.0\EntityFrameworkCoreMigrationsDemo.dll Build succeeded. Startup.cs(45,13): warning CS4014: Because this call is not awaited, execution of the current method continues before the call is completed. Consider applying the 'await' operator to the result of the call. [C:\WorkSpacesC\DotNetCore\EntityFrameworkCoreMigrationsDemo\EntityFrameworkCoreMigrationsDemo\EntityFrameworkCoreMigra

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值