EF database-first approach how to add new not null column to production table and manage at code level

asp.net-mvc ef-database-first entity-framework entity-framework-6

Question

Entity Framework 6 and a database-first strategy are both used in my ASP.NET MVC 4 application. The current goal is to introduce a new column to the production environment.Deposit column is not empty in the table. Numerous data points are included in the production table.

Can somebody advise me on how to handle these modifications using a code-first approach? What should I do? Entity Framework is new to me.

1
0
8/30/2018 2:12:51 PM

Popular Answer

If you decide to go with the database-first strategy, you may carry out the following:

execute a script to migrate the database:

ALTER TABLE Deposit ADD <column_name> INT NULL
GO
UPDATE Deposit SET <a valid not null values for your column>
GO
ALTER TABLE Deposit  ALTER COLUMN <column_name> INT NOT NULL
GO

2) You must update as you are employing the db-first strategy.edmx model (.edmx ) that is already tied to the database. If my memory serves me properly, Solution Explorer's context menu offers this option.

0
8/30/2018 2:44:56 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow