首先,实体框架核心代码不支持哪些SQL Server 2017功能? [英] What SQL Server 2017 features are not supported in Entity Framework Core code first?

查看:88
本文介绍了首先,实体框架核心代码不支持哪些SQL Server 2017功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的团队正在考虑先使用Entity Framework Core代码来帮助对数据库进行建模.根据此处的文章,我们可以同时具有数据库项目和EF模型.

Our team is thinking of utilizing Entity Framework Core code-first to help model the database. We can have both DB projects and EF models, as per article here Database Projects vs. Entity Framework Database Migrations utilizing schema compares, just trying to figure out what will be the source of truth?

实体框架是否支持SQL Server SSDT数据库项目中的所有功能?

Does Entity Framework support all features in SQL Server SSDT Database Projects?

EF Core 2不支持哪些功能? (例如,它不支持以下任何一项:触发器,视图,函数,存储过程,加密密钥,证书,数据库属性(ansi null,带引号的标识符),分区)

What features does EF Core 2 not support? (eg, does it not support any of following: triggers, views, functions, stored procedures, encryption keys, certificates, db properties (ansi null, quoted identifier), partitions)

我正在尝试找到Microsoft资源.

I am trying to locate the Microsoft Resource.

推荐答案

tl; dr 数据库项目功能丰富,但数据库优先.迁移是代码优先的,但是内置的数据库功能非常有限.

tl;dr Database Projects are feature-rich, but database-first. Migrations is code-first, but has a very limited built-in set of database features.

对于许多人来说,比较数据库项目和迁移是无关紧要的.它们代表使用实体框架的两种不同模式.迁移是代码优先,迁移是数据库优先.当然,您可以使用迁移来控制数据库架构,并且可以使DP与生成的数据库保持同步,从而满足DBA(如链接所示).但是两者都过着各自的生活,没有单一真相.

For many people it won't be relevant to compare Database Projects and Migrations. They represent two different modes of working with Entity Framework. Migrations is code-first, DP is database-first. Sure, you can use migrations to control the database schema and besides that keep a DP in sync with the generated database to satisfy DBAs (as the link suggests). But both lead their own separate lives and there's no Single Source Of Truth.

因此,如果您不确定要选择哪种工作模式,则将它们进行比较很有用.

So comparing them is useful if you're not sure yet wich working mode you're going to choose.

对我来说,最重要的区别是DP在比较数据库时将覆盖 all 个数据库对象并检测它们之间的 all 更改.迁移仅检测数据库和映射模型之间的更改.并且用于生成数据库对象的选项集非常有限.对于所有其他需要的内容,您必须将SQL语句插入迁移代码中.这些陈述是您自己的责任.您必须弄清楚自己是否需要迁移ALTER PROCEDURE语句(例如).如果脚本和数据库在这方面有所不同,EF不会抱怨.

For me the most important difference is that DP will cover all database objects and detect all changes between them when comparing databases. Migrations only detect changes between a database and the mapped model. And the set of options for generating database objects is very limited. For everything you need additionally you have to inject SQL statements into the migration code. These statements are your own responsibility. You have to figure out yourself if a migration needs an ALTER PROCEDURE statement or not (for example). EF won't complain if the script and the database differ in this respect.

这就是为什么我从不热衷于迁移的主要原因.维护存储,文件组,特权,归类以及所拥有的内容等成熟的数据库架构几乎是不可能的.

This is the main reason why I've never been a great fan of migrations. It's virtually impossible to maintain a mature database schema including storage, file groups, privileges, collations, and what have you.

DP的另一个优点是,与源代码控制结合使用时,它们很棒.每个数据库对象都有其自己的文件,并且很容易检查每个对象的更改历史记录.对于生成的迁移,这是不可能的.确实,许多中间更改可能永远不会对生成的迁移产生影响.

Another advantage of DP is that they're great in combination with source control. Each database object has its own file and it's very easy to check the change history of each individual object. That's not possible with generated migrations. Indeed, many intermediate changes may never make it to a generated migration.

当然,迁移的明显优势是可以进行运行时检查(尽管不完整),以检查代码和数据库是否匹配.在数据库优先项目中,您需要为此创建自己的机制.

Of course the obvious advantage of migrations is the possibility to do a runtime check (albeit incomplete) whether the code and the database match. In database-first projects you need to create your own mechanism for that.

这篇关于首先,实体框架核心代码不支持哪些SQL Server 2017功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆