我想知道模板10是否与netstandard2.0兼容。下面列出了一个非常简单的库:
using Microsoft.EntityFrameworkCore;
using System;
using System.ComponentModel.DataAnnotations;
namespace TransactionModel
{
public class MyTransaction
{
[Key]
public Guid TransactionId { get; set; }
public string BankID { get; set; }
public string MerchantID { get; set; }
public DateTime TransactionDate { get; set; }
public string TransactionDescription { get; set; }
public float TransactionAmount { get; set; }
public string TransactionComments { get; set; }
}
public class TransactionContext : DbContext
{
public DbSet<MyTransaction> transactionBatch { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionBuilder)
{
optionBuilder.UseSqlite("Data source=transactions.db");
}
}
}下面列出了这个库csproj文件:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.0;netstandard2.0</TargetFrameworks>
<!--<TargetFramework>netstandard2.0</TargetFramework>-->
<RuntimeFrameworkVersion>2.0.3</RuntimeFrameworkVersion>
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="microsoft.entityframeworkcore.Sqlite" Version="2.0.1" />
<PackageReference Include="microsoft.entityframeworkcore.tools" Version="2.0.1" />
</ItemGroup>
</Project>我已经安装了包Microsoft.EntityFrameworkCore.Sqlite和Microsoft.EntityFrameworkCore.Tools,然后添加-迁移成功搭建数据库。
但是当我尝试引用TransactionModel时,编译器生成了一堆错误,但我认为这是主要的错误:“无法解析程序集或Windows元数据文件。”

我已经附上了我的vs2017解决方案的图像。我还没有在T10上写任何代码,我刚刚创建了T10模板,引用了我的库,vs2017生成了错误。如果我使用UWP,我不会得到这样的错误...
所以我的问题是,是否有可能在EntityFrameworkCore和netstandard2.0中使用T10?有没有办法绕过这个错误?

发布于 2018-02-20 01:25:45
不可能从.NET核心项目创建对模板10库的依赖,因为模板10库是一个通用的Windows库。这适用于当前版本的模板10,也适用于下一版本的模板10。为什么?因为模板10是为增强UWP应用程序开发而构建的库,因此需要Windows命名空间,如您所知,该命名空间不是.NET标准的一部分。怎么会这样呢?Windows命名空间永远不能是跨平台的。尽管如此,Windows10(新版本)的基本接口并不是从.NET标准库Prism.Core派生出来的。这意味着导航接口和MVVM类都是外部的,可以继承旁路模板10。这回答了你的问题,我希望你能理解事情的技术原因。
https://stackoverflow.com/questions/48686821
复制相似问题