Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some Changes in Coding the Web API for Dotnet 6 #2

Closed
An0rangetree opened this issue May 16, 2022 · 1 comment
Closed

Some Changes in Coding the Web API for Dotnet 6 #2

An0rangetree opened this issue May 16, 2022 · 1 comment

Comments

@An0rangetree
Copy link

  • 问题:在appsettings.json中配置完ConnectionStrings之后,想去startup.cs写services.AddDbContext,但是Dotnet 6没有startup.cs

  • 解决:官方文档里有一个示例

image
这边尝试
image
官方示例文档中还有个
image
这么写就不报错了
image

  • 效果:也可以生成迁移文件

image
以及数据库
image

  • 追问:请问我这样写有没有问题,初学者只能依葫芦画瓢,具体尝试的代码意味着什么并不完全理解……
@An0rangetree
Copy link
Author

An0rangetree commented Jul 28, 2022

再次来参考的时候,遇到了新的Bug:
PM> Add-Migration MyWPF Build started... Build succeeded. Unable to create an object of type 'MyWPFContext'. For the different patterns supported at design time, see https://go.microsoft.com/fwlink/?linkid=851728

通过网上查询,通过在"MyWPFContext"文件中添加一个构造函数和一些override来解决这个问题,可以参考:这个网址

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant