报错内容:
ex:An exception has been raised that is likely due to a transient failure. Consider enabling transient error resiliency by adding 'EnableRetryOnFailure' to the 'UseSqlServer' call.
InnerException:无法打开登录所请求的数据库 "win7bc"。登录失败。
用户 'sa' 登录失败。
解决方法:
检查连接字符串,数据库名,用户名密码,IP等。
报错内容:
The DbContextOptions passed to the db1DbContext constructor must be a DbContextOptions<db1DbContext>.
When registering multiple DbContext types, make sure that the constructor for each context type has a DbContextOptions<TContext> parameter rather than a non-generic DbContextOptions parameter.
解决方法:
把:public db1DbContext(DbContextOptions options) : base(options)
写成:
public db1DbContext(DbContextOptions<db1DbContext> options) : base(options)
--
使用 泛型 DbContextOptions<TContext>