【发布时间】:2018-07-19 02:26:35
【问题描述】:
我想知道模板 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,我没有收到这样的错误...
所以我的问题是是否可以将 T10 与 EntityFrameworkCore 和 netstandard2.0 一起使用?有没有办法绕过这个错误?
【问题讨论】:
-
更正它不兼容。#soon 当 10.2 发布时,这在重构开发中很重要。但是你不需要 .netstandard 2 在 uwp 中使用 sqlite ...如果你只是使用 EFCore 以前的版本工作。
-
您可以在aka.ms/template10 查看模板 10 的当前版本并亲自查看。下一个版本即将推出。
标签: visual-studio-2017 entity-framework-core template10 .net-standard-2.0