简体   繁体   English

在不崩溃 LINQ/ADO.NET Entity Framework + SQL 服务器的情况下可以安全地进行哪些架构更改

[英]What schema changes are safe to make without crashing LINQ/ADO.NET Entity Framework + SQL Server

I am connecting to SQL Server 2016 using LINQ/ADO.NET Entity Framework and I want to make schema changes to my database live in production.我正在使用 LINQ/ADO.NET 实体框架连接到 SQL Server 2016,并且我想在生产中对我的数据库进行架构更改。 The way these changes are made is:进行这些更改的方式是:

  1. Change the schema in the database更改数据库中的架构
  2. Deploy a new version of the software that takes advantage of it部署利用它的软件的新版本

What I want to avoid is downtime after 1 is done but before 2 occurs.我要避免的是在 1 完成后但在 2 发生之前的停机时间。

In the past sometimes I have had issues where changing the schema will cause ADO.NET Entity Framework/LINQ to die.在过去,有时我会遇到更改架构会导致 ADO.NET 实体框架/LINQ 死掉的问题。 It seems to do some type of schema validation on startup.它似乎在启动时进行了某种类型的模式验证。 In the past I believe this occurred when I deleted an unused field from a table.过去,我相信当我从表中删除未使用的字段时会发生这种情况。

So my question is, what types of schema changes are "safe" and "unsafe" to make on the database, such that they do not cause ADO.NET Entity Framework to start throwing errors?所以我的问题是,在数据库上进行哪些类型的架构更改是“安全的”和“不安全的”,这样它们才不会导致 ADO.NET 实体框架开始抛出错误? Can I add as many fields and tables that I wish with guaranteed safety?我可以在保证安全的情况下添加尽可能多的字段和表格吗?

Assuming you don't use EF Migrations, EF won't validate or modify the database schema.假设您不使用 EF 迁移,EF 将不会验证或修改数据库架构。 And EF always generates queries with explicit column names.并且 EF 总是生成具有显式列名的查询。 So long as you don't modify the table and column names EF expects, or make any EF entity's key property(s) non-unique EF should be fine.只要您不修改 EF 期望的表名和列名,或者使任何 EF 实体的关键属性不唯一 EF 应该没问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM