首页 > 解决方案 > 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).

标签: f#entity-framework-coredomain-driven-design

解决方案


可以将 EF 与 F# 一起使用,尽管不支持 DU(在 Sql Server/PostGres 中,DU 甚至看起来像什么?)我在一个宠物项目中这样做,但是我有大量映射器可以在不可变我的域模型和可变更改的跟踪实体的记录。我不一定相信这是最好的方法。可以将表映射到 F# 记录,但由于 EF 使用更改跟踪来创建更新,因此我不确定由于失去可变性是否有显着优势。如果您正在执行一堆“仅获取”调用,那么 dapper 会明显更简单且更易于使用。

如果您试图避免直接管理数据库,例如创建/编辑表/列/PKs/FK,那么有很多工具可以让您轻松做到这一点,例如 Sql Server Management Studio 或 Navicat。我很少需要进入 SQL 来调整架构。与mssql-scripter or结合使用pgdump,对您的数据库进行版本控制很简单。当然,我假设您使用的是 MSSQL 或 PostGres。


推荐阅读