连接字符串写错导致,修改后OK。
原来的:
<connectionStrings> <add name="EFDbContext" connectionString="Data Source=Brian-PC-c;Initial Catalog=SportsStore;Persist Security Info=True;User ID=sa;Password=global" providerName="System.Data.SqlClient"/> </connectionStrings> 修改后的: <connectionStrings> <add name="EFDbContext" connectionString="Data Source=Brian-PC;Initial Catalog=SportsStore;Persist Security Info=True;User ID=XXX;Password=XXX" providerName="System.Data.SqlClient"/> </connectionStrings>