@nepsy

Scaffold-DbContext. Reverse engineering. Как быть с ненулевыми?

Есть таблица

CREATE TABLE [dbo].[Orders] (
[Id] INT IDENTITY (1, 1) NOT NULL,
[UserId] INT NOT NULL,
[IsProcessed] BIT DEFAULT (CONVERT([bit],(0))) NOT NULL,
CONSTRAINT [PK_Orders] PRIMARY KEY CLUSTERED ([Id] ASC)
);


Создаю классы вызывая Scaffold-DbContext (DBFirst):

PM> Scaffold-DbContext "Server=(localdb)\mssqllocaldb; Database=TestDb; Trusted_Connection=true;" Microsoft.EntityFrameworkCore.SqlServer
Build started...
Build succeeded.


To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263.
The column 'dbo.Orders.IsProcessed' would normally be mapped to a non-nullable bool property, but it has a default constraint. Such a column is mapped to a nullable bool property to allow a difference between setting the property to false and invoking the default constraint. See https://go.microsoft.com/fwlink/?linkid=851278 for details.


Создается класс:

public partial class Order
{
public int Id { get; set; }
public int UserId { get; set; }
public bool? IsProcessed { get; set; }
}


Проблема известная и описанна тут. Есть ли какие-нибудь соображения по этому поводу?
  • Вопрос задан
  • 151 просмотр
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
26 апр. 2024, в 09:18
500 руб./в час
26 апр. 2024, в 06:46
1500 руб./в час
26 апр. 2024, в 05:31
1000 руб./за проект