Deutsch
Germany.ruФорумы → Архив Досок→ Программирование

EF Core. scaffold-dbcontext. DBFirst

23.08.21 09:41
EF Core. scaffold-dbcontext. DBFirst
 
  nepsy знакомое лицо
nepsy

Есть таблица



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; }
}



Изначально поле в таблице было не нулевым, а в классе создается нулевым.
Такая особенность и как с этим бороться не понятно. Править каждый раз в ручную, при наличае более 15 классов не хочется. Есть ли какие-нибудь соображения по этому поводу?

 

Перейти на