最近部署使用.net core 有些时间会爆出下面这样的错误,
InvalidOperationException: An attempt was made to use the context while it is being configured. A DbContext instance cannot be used inside OnConfiguring since it is still being configured at this point.
翻译:nvalidOperationException:尝试当它被配置使用上下文。DbContext的实例不在onconfiguring因为它仍然是被配置在这一点上的应用。
DbContext 是注入的
在ef core上下文中你在OnConfiguring方法中又实例化了一次
设为单列就可以了