f# - F# On Server and Database
问题描述
I'm starting a new webapi Project
For domain implementation I m going to use F#.
To Store Data I m going to use Database, Which I haven't decided.
ORM if it will be C# I would be using Entity Framework with no question in my mind.
But using F# + Entity Framework I have following questions
1- Bcs of my domain is in F# all my Entities and Value Objects will be in F#. Does EF core will work with it ? (eg Discriminated Union)
2- if not what are different Options I have ?
3- What Options do u use?
feel free to share sample projects
I don't want to use type providers bcs I don't want to manage DB Manually (not at start).
解决方案
可以将 EF 与 F# 一起使用,尽管不支持 DU(在 Sql Server/PostGres 中,DU 甚至看起来像什么?)我在一个宠物项目中这样做,但是我有大量映射器可以在不可变我的域模型和可变更改的跟踪实体的记录。我不一定相信这是最好的方法。可以将表映射到 F# 记录,但由于 EF 使用更改跟踪来创建更新,因此我不确定由于失去可变性是否有显着优势。如果您正在执行一堆“仅获取”调用,那么 dapper 会明显更简单且更易于使用。
如果您试图避免直接管理数据库,例如创建/编辑表/列/PKs/FK,那么有很多工具可以让您轻松做到这一点,例如 Sql Server Management Studio 或 Navicat。我很少需要进入 SQL 来调整架构。与mssql-scripter or结合使用pgdump
,对您的数据库进行版本控制很简单。当然,我假设您使用的是 MSSQL 或 PostGres。
推荐阅读
- python - 将列组合到一个日期时间对象 Python
- python-3.x - 旋转数据框后如何再次找到索引?
- automation - 如何在任何地方使用自动化提取电子签名?
- r - 将选定的变量输出到全局环境 R 函数
- javascript - js 全局和局部范围
- angular - 使用解构如何在具有默认自定义类型的函数中接收参数
- reactjs - 当我在 childComponent 中提交表单时,我的页面在 ReactJS 中刷新
- reactjs - 如何为 Ionic 5 React 应用程序的每个页面获取页面转换?
- flutter - 将敲击声音添加到 like_button 颤动
- c# - RestSharp 在 ASP.NET Core 3.1 中导致内部服务器错误