Context:
我需要在我的本地计算机(Macbook)上运行一个“遗留”.Net 应用程序...(我们的大部分堆栈是 dotnetcore),但这个特定的应用程序有点旧。
虽然我确实意识到可能只启动一个 Windows 虚拟机并在那里构建它会更容易,但我正在尝试构建项目(并使用 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" />
Problem:
我认为发生的情况是常规构建任务不会从.edmx
,但至于如何在我当前的环境下做到这一点......我开始认为这是不可能的。
Error:
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 机器?