支架

编程入门 行业动态 更新时间:2024-10-25 15:28:58
本文介绍了支架-DbContext抛出错误“找不到组件”。在核心中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用核心和实体框架核心1.1.0。在 Package Manager控制台

I am using core and entity framework core 1.1.0. while trying the following command in Package Manager Console

Scaffold-DbContext "Server=MyServer\\MyInstance;Database=MyDB;user=MyUsername;password=MyDbPassword;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -t Table1,Table2

我收到此错误

找不到程序集'D:\Work\Projects\src\MyProject\src\MyProject.Api .\bin\Debug\net461\win7-x64\MyProject.Data.exe'。

Could not find assembly 'D:\Work\Projects\src\MyProject\src\MyProject.Api.\bin\Debug\net461\win7-x64\MyProject.Data.exe'.

MyProject.Data是一个网络核心库。 MyProject.Api是完整框架核心api,它引用MyProject.Data。

MyProject.Data is a net core library. MyProject.Api is a full framework core api, which references the MyProject.Data.

MyProject.Data的project.json文件

project.json file of MyProject.Data

{ "version": "1.0.0-*", "dependencies": { "Microsoft.EntityFrameworkCore.Design": "1.1.0", "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0", "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.1.0", "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final" }, "frameworks": { "net461": {} } }

对我有任何建议吗?

推荐答案

不确定这是否是一个错误,但是 scaffold-dbcontext 命令在启动项目中寻找程序集。

Not sure if this is a bug, but scaffold-dbcontext command looks for the assembly in startup project.

此问题有两种解决方法

  • 右键单击要在其上运行此命令的项目(您的情况是MyProject.Data),然后选择设为启动项目。
  • 您可以将开关添加到脚手架-DBContext 命令在运行命令时将特定项目设置为启动项目。 这是您需要在命令末尾添加的内容...

  • Right click on the project you intend to run this command on (in your case, it is MyProject.Data) and select Set as startup project.
  • You can add a switch to scaffold-DBContext command to set a particular project as startup project while running the command. This is what you need to add at the end of command...

    -StartupProject MyProject.Data

  • 更多推荐

    支架

    本文发布于:2023-11-14 19:11:29,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1588293.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:支架

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!