【发布时间】:2019-08-27 04:40:51
【问题描述】:
上下文:
我需要在我的本地机器上运行一个“旧版”.Net 应用程序,它是一台 Macbook...(我们的大部分堆栈都是 dotnetcore),但这个特定的应用程序有点旧。
虽然我确实意识到启动 Windows VM 并在其中构建它会容易得多,但我正在努力构建项目(并使用 MONO 运行)
到目前为止,我已经通过在.csproj 中添加一些条件检查解决了一些问题,这使得应用程序构建和运行......几乎没有,因为当我点击第一个检查数据库连接的 API 时它就死了.
当前设置:
- Mono JIT 编译器版本 5.18.1.3
- .Net 目标 4.6.1
- Rider IDE(我也安装了 VS for OSX)
- EF6.1.3
项目的结构如下:
Project.Data
- App.Config
- DataModel.edmx
Project.Api (which references the Project.Data)
- Web.Config
两者都包含以下连接字符串(为简洁起见,缩进):
<add name="SomeEntities"
connectionString="
metadata=
res://*/DataModel.csdl|
res://*/DataModel.ssdl|
res://*/DataModel.msl;
provider=System.Data.SqlClient;
provider connection string=
"
data source=somedb;
initial catalog=some_catalog;
user id=some_id;
password=some_password;
App=EntityFramework;
"
"
providerName="System.Data.EntityClient" />
问题:
我认为发生的事情是常规构建任务不会从 .edmx 生成正确的文件,但至于如何在我当前的环境中执行此操作......我开始认为这是不可能的。
错误:
Unable to load the specified metadata resource.
at System.Data.Entity.Core.Metadata.Edm.MetadataArtifactLoaderCompositeResource.LoadResources
我看过各种关于修改连接字符串的帖子,结果各不相同,但从未导致应用程序正常运行。
更改为 metadata=res://*/; 会导致:
Argument 'xmlReader' is not valid. A minimum of one .ssdl artifact must be supplied.
at System.Data.Entity.Core.EntityUtil.CheckArgumentEmpty[T]
更改为标准的 SqlConnection 字符串:
System.Data.Entity.Infrastructure.UnintentionalCodeFirstException:
The context is being used in Code First mode with code that was generated from an EDMX file for either Database First or Model First development. This will not work correctly. To fix this problem do not remove the line of code that throws this exception. If you wish to use Database First or Model First, then make sure that the Entity Framework connection string is included in the app.config or web.config of the start-up project. If you are creating your own DbConnection, then make sure that it is an EntityConnection and not some other type of DbConnection, and that you pass it to one of the base DbContext constructors that take a DbConnection. To learn more about Code First, Database First, and Model First see the Entity Framework documentation here: http://go.microsoft.com/fwlink/?LinkId=394715
问题:
这完全有可能吗,还是我应该恢复获得一台 Windows 机器?
【问题讨论】:
标签: .net entity-framework msbuild mono