Xamarin에서 Entity Framework Core를 사용할 때의 참고 사항
4652 단어 EntityFramework_CoreXamarin
Xamarin에서 Entity Framework Core를 사용할 때의 참고 사항
소개
Xamarin에서 Entity Framework Core를 사용할 때 몇 가지 작업이 있었기 때문에 해결 방법에 대한 메모를 제공합니다.
마이그레이션 도구
Xamarin 프로젝트에 대해 Entity Framework Core 마이그레이션 도구의 dotnet ef
명령을 직접 실행할 수 없습니다. 콘솔 응용 프로그램이 Xamarin 프로젝트를 참조하도록 명령을 실행해야 합니다.
.NET Core 콘솔 응용 프로그램을 솔루션에 추가하고 콘솔 응용 프로그램 참조 설정에서 Xamarin 프로젝트를 추가합니다.

콘솔 애플리케이션 프로젝트의 디렉토리에서 dotnet ef
명령을 실행하십시오.

dotnet ef migrations add [マイグレーションの名前] -p [DbContext を持つプロジェクトの csproj ファイル]
그러면 마이그레이션 관련 코드를 생성할 수 있습니다.

System.Buffuers와 관련된 빌드 오류
Android 프로젝트를 빌드하면 다음과 같은 빌드 오류가 발생할 수 있습니다.
Can not resolve reference: System.Buffers
, referenced by System.Memory
. Please add a NuGet package or assembly reference for System.Buffers
, or remove the reference to System.Memory
.
이 경우 NuGet을 사용하여 System.Buffers
를 설치하면 해결할 수 있습니다.
Linker 설정
Release 빌드 시 링커는 사용(또는 참조)되지 않는 어셈블리, 형식 및 멤버를 파괴하므로 Entity Framework Core에서 사용하는 클래스를 파기하지 않도록 Linker를 구성해야 합니다. 다음과 같은 xml 파일을 iOS, Andorod 프로젝트에 추가하여 빌드 작업을 설정해야 합니다.
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="mscorlib">
<type fullname="System.String">
<method name="Compare"></method>
<method name="CompareTo"></method>
<method name="ToUpper"></method>
<method name="ToLower"></method>
</type>
</assembly>
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions.Expression`1"></type>
<type fullname="System.Linq.Queryable"></type>
</assembly>
</linker>
Visual Studio 빌드 작업에서 [LinkDescription]을 설정합니다.

SQLitePCL.Batteries_V2.Init() 호출
SQLite 데이터베이스를 사용하는 경우 응용 프로그램을 초기화할 때 SQLitePCL.Batteries_V2.Init()
를 호출해야 합니다.
SQLitePCL.Batteries_V2.Init();
사이고에게
GitHub의 Issue에서 Entity Framework Core가 제대로 작동하지 않을 때의 해결 방법이 요약되어 있습니다. 이쪽도 정기적으로 워치 해 두면 좋을지도 모릅니다.
dotnet ef migrations add [マイグレーションの名前] -p [DbContext を持つプロジェクトの csproj ファイル]
<?xml version="1.0" encoding="utf-8" ?>
<linker>
<assembly fullname="mscorlib">
<type fullname="System.String">
<method name="Compare"></method>
<method name="CompareTo"></method>
<method name="ToUpper"></method>
<method name="ToLower"></method>
</type>
</assembly>
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions.Expression`1"></type>
<type fullname="System.Linq.Queryable"></type>
</assembly>
</linker>
SQLitePCL.Batteries_V2.Init();
Reference
이 문제에 관하여(Xamarin에서 Entity Framework Core를 사용할 때의 참고 사항), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://qiita.com/tafuji/items/c2a0231f248021599250텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념
(Collection and Share based on the CC Protocol.)