Entity Framework Core Update Database
Entity Framework Core Update Database
当数据结构改变后更新数据库
方式一:
菜单-> Tooles->External Tools-> Add
Title:Update DbContextCommand:dotnet.exeArguments:ef dbcontext scaffold "your-connection-string" Microsoft.EntityFrameworkCore.SqlServer --output-dir=Models --forceInitial Directory:$(ProjectDir)- 点击Apply 和 Ok
- Tools菜单会出现 Update DbContext点击即可
- 连接字符串貌似得使用带有密码的否则会报instance failure
方式二:
如果是Package Manager Console:
Scaffold-DbContext "Server=(localdb)\v11.0;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -Force如果是CLI Commands:
dotnet ef dbcontext scaffold "Server=(localdb)\v11.0;Database=Blogging;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Models -f这会导致指定文件夹的内容被重写.

浙公网安备 33010602011771号