I decided to use int
instead of DateTime
at this stage. I created a migration with add-migration
, but that failed and said I have to run CONVERT
command manually. I don't know SQL Server, so I went to the Visual Studio Server Explorer and used the Table design tool to change the values to int
and ran Update
. It succeeded, however, when I try to save something to my database it throws an error:
System.Data.SqlClient.SqlException: 'Cannot drop database "AppDbContext" because it is currently in use.'
I deleted manually the database files, located in my App_Data
folder and rebuilt my app, but same error occurs. When I check the table structure with the design tool, it reflects my changes - the desired column is now int
instead of DateTime
.
This is the code that accesses the database:
db.Contests.Add(contest);
Contests
is indeed the table I changed, but the database structure seems alright. I don't understand why it attempts to drop the database. How can I fix it?