c# - 如何在跨解决方案共享的数据库项目中引用 IdentityDbContext
问题描述
我想利用 ASP.NET Core 项目的 Visual Studio 模板中现成的 IdentityDbContext。但是,我希望我的实体和迁移存在于共享项目中,以供解决方案的不同组件(Web、API、后台服务等)引用。
我的共享数据库项目将是一个 .NET Standard 项目,但看起来我必须添加对Microsoft.AspNetCore.Identity.EntityFrameworkCore
. 向标准项目引入对专门用于 ASP.NET 的核心程序集的依赖项感觉很奇怪。这会带来什么问题吗?
解决方案
You must inherit some of Identity classes(IdentityUser) for your Entity objects so you must reference the Microsoft.AspNetCore.Identity.EntityFrameworkCore
but I do not recommend to store Identity classes with other Entity classes related to your business layer.
Identity is about infrastructure of your project. Just store Identity related classes Dbbontext, entity classes and services on the same project that you already store Db access codes thats reference EntityFrameworkCore.
Holding two different projects on solution that reference EntityFrameworkCore just a violation of seperation of concerns not more. If you want to hold 2 different projects just use same versions of EfCore.
推荐阅读
- python - Python MYSQL 使用 OR 和 AND 运算符比较多个表
- python - PyQt5如何使用python在迭代循环中更新单元格值Qtablewidget
- google-cloud-platform - 无法启动 GCE VM 实例“该区域没有足够的资源”
- r - 继承或从 R 中的另一个函数调用该函数
- c - 使用共享库和多个项目设置 STM32 解决方案
- c# - 在 C# 中合并两个 XML 文件
- python - 使用优先级规则排队任务
- discord.py - How to make a discord.py converter pass thorugh a argument and time return a value
- user-interface - XFCE 对话框中的操作按钮位置错误
- typo3 - TYPO3 遮罩元素 - 错误的输出