Adding a new property to an existing model

raysefo

Well-known member
Joined
Feb 22, 2019
Messages
219
Programming Experience
10+
Hi,

I wonder if it is a good practice to add this line of code to production?

error:
System.InvalidOperationException HResult=0x80131509 Message=The model backing the 'GameContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269). Source=<Cannot evaluate the exception source> StackTrace: <Cannot evaluate the exception stack trace>

Global.asax:
C#:
Database.SetInitializer<GameContext>(null);
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
4,431
Location
Chesapeake, VA
Programming Experience
10+

raysefo

Well-known member
Joined
Feb 22, 2019
Messages
219
Programming Experience
10+
Actually, API is already running for quite some time. Just quickly add some fields to an existing table on my production.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
4,431
Location
Chesapeake, VA
Programming Experience
10+
I'll let the EF practitioners here weigh in.
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
4,431
Location
Chesapeake, VA
Programming Experience
10+
There are. I'm the lone anti-EF guy left here. The other anti-EF guy doesn't visit anymore.
 

raysefo

Well-known member
Joined
Feb 22, 2019
Messages
219
Programming Experience
10+
I have an ASP.NET Web API which is already running for quite some time on production. I need to quickly add some fields to an existing model/table on my production. Sometimes it is tedious dealing with EF migrations and I don't feel comfortable with migrations. So adding this additional property to the model and manually altering the database table seems OK for me. Any suggestions from EF guys here?
 

Skydiver

Staff member
Joined
Apr 6, 2019
Messages
4,431
Location
Chesapeake, VA
Programming Experience
10+
I don't feel comfortable with migrations
That would indicate that you don't have enough end-to-end integration testing. Well designed tests build confidence.
 
Top Bottom