0
votes

I followed the instruction from Microsoft to scaffold an existing AzureSQL database and WAS SUCCESSFULLY access to data before. Here was the command I used

"PM> Scaffold-DbContext "Server=tcp:******.database.windows.net,1433;Initial Catalog=******;Persist Security Info=False;User ID=******;Password=******;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models>

However last week my company change the password of the database and all of sudden the Db Context model stop working. I have updated the connection string correctly and even re-scaffold the models however it still not working. Note that I tried to connect through SqlConnection with that connection string or login into SQL Sever Explorer and they are still all successful. The data team said they only changed the password and nothing more. However, only with EF core no longer work. There is no message error but if I create an object DbContext and see that 99% of the dbsets are empty. Below is my debug photo.

Debug photo

Has anyone face the problem before and can help me with that. Thanks in advance. I am new.

1
Hi, I have tried to figure out what is the problem. The problem come from csproj file I set <Nullable>enable</Nullable>. If I remove it then everything work fine again. I dont know why it affect the DbContext and make it return empty set but that is the problem. - J Nguyen
Congratulations! You have figure out the problem by remove '<Nullable>enable</Nullable>' in csroj file. ,I help you post it as answer then Ohers can know the problem is solved. You could accept(mark) it as answer. This can be beneficial to other community members. Thank you. - Leon Yue

1 Answers

0
votes

Congratulations you error is solved by yourself:

The problem come from csproj file I set enable. If I remove it then everything work fine again.

I help you post it as answer and this can be beneficial to other community members.