| DataDirectory目录|对于EF更新数据库 [英] |DataDirectory| for EF Update-Database

查看:94
本文介绍了| DataDirectory目录|对于EF更新数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何定义| DataDirectory |对于EF命令更新迁移的连接字符串中的WPF项目?有很多解决方案可以添加:AppDomain.CurrentDomain.SetData(DataDirectory,***);
但它只有在应用程序运行时才起作用。我不运行应用程序 - 只是想创建和迁移数据库

How to define |DataDirectory| for WPF project that is in Connection String for EF command "Update-Migration"? There are a lot solutions to add : AppDomain.CurrentDomain.SetData("DataDirectory", ***); but it works only if application runs. I do not run application - just want to create and migrate Database

推荐答案

我有同样的问题,可能这是一些不寻常的行为,但最好,我发现 - 它是为update-database命令指定连接字符串参数:

I have the same question, may be this some uncommon behavior, but best, what i found - it is specify connection string parameter for update-database command:

update-database -ConnectionString "Data Source=(LocalDB)\v11.0;AttachDbFilename=C:\Users\User\Database.mdf;Integrated Security=True" -ConnectionProviderName System.Data.SqlClient 

这篇关于| DataDirectory目录|对于EF更新数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆