我有一个适用于谁的 DAL 的工作应用程序我刚刚添加了 EF5 迁移。使用 Enable-Migrations 和 Add-Migrations 时,出现以下错误。
Add-Migration EnforeUniqueIndexes
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
System.TypeInitializationException: The type initializer for 'Parkalot.Database.Context' threw an exception. --->
System.ArgumentException: The argument 'nameOrConnectionString' cannot be null, empty or contain only white space.
我怀疑它正在尝试连接到数据库,但该连接未在该项目中定义。它在另一个充当 BLL 并将连接字符串传递给 DAL 的程序集中定义。
我不想在 DAL 中(在应用程序设置或代码中)保留连接字符串的副本,并且不确定如何解决此问题。请指教。
更新:这是 Multi-Tenancy SaaS 应用程序,因此需要根据上下文使用不同的连接字符串调用 DAL。
最佳答案
在这里找到答案:http://coding.abel.nu/2012/03/ef-migrations-command-reference/#Add-Migration .
我仍然必须将连接字符串添加到 DAL 项目,但仅供包管理器使用。
关于c# - 添加迁移抛出 SQL ConnectionString 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16872739/