I wonder if template 10 is compatible with netstandard2.0. I have a very simple library listed below:
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");
}
}
}
This library csproj file listed below:
<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>
I have installed package Microsoft.EntityFrameworkCore.Sqlite and Microsoft.EntityFrameworkCore.Tools and then add-migration to scaffold the database successfully.
But when I tried to make reference to TransactionModel, the compiler generated a bunch of errors, but I think this is the main error: " Cannot resolve Assembly or Windows Metadata file.."
I have attached a image of my vs2017 solution. I have written no code on T10 yet, I have just created T10 template, made reference to my library and vs2017 has generated the errors. If I use UWP, I did not get such error...
So my question is whether it is possible to use T10 with EntityFrameworkCore and netstandard2.0? Is there a way to go around the error?
It is not possible to create a dependency FROM a .NET Core project ON the Template 10 library because the Template 10 library is a Universal Windows Library. This is true with the current version of Template 10. This will also be true with the next version of Template 10. Why? Because Template 10 is a library built to enhance UWP application development, and, as a result, requires the Windows namespace which, as you know, is not part of .NET Standard. How could it be? The Windows namespace could never be cross-platform. That being said, the fundamental interfaces of Windows 10 (new version) are not derived from Prism.Core which is a .NET Standard library. This means the navigation interfaces and MVVM classes are all external and can be inherited side-stepping Template 10. This answers your question, I hope you understand the technical reasons things are as they are.