Adding a new property to an existing model

raysefo

Well-known member
Joined
Feb 22, 2019
Messages
362
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);
 
Actually, API is already running for quite some time. Just quickly add some fields to an existing table on my production.
 
I'll let the EF practitioners here weigh in.
 
There are. I'm the lone anti-EF guy left here. The other anti-EF guy doesn't visit anymore.
 
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?
 
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.
 

Latest posts

Back
Top Bottom