AugustM
AugustM

Reputation: 87

Entity Framework with .netstandard 2.0 and SQL Server

I am a novice in the .net world and developing a cross platform Xamarin app. I need a nice way to communicate with my SQL Server database. I looked into the Entity Framework, but I don't understand how to use this to access a SQL Server.

I found a few examples using SQLite and DbContext from the Entity Framework Core package, but none that specifies a connection to a full SQL Server. I wanted to use the ADO.net Entity Data model, but this is not available for .netstandard projects as far as I understand.

I am asking for guidance in the best way to configure the communication with the SQL Server for this project setup. Is is a database first approach. I would prefer an easy way to map my db models to models the in core project, but I don't mind doing it manually. Most importantly is help on setting up a class that can query database objects and map them to my model classes. My database uses SQL Server authentication if that is important.

Upvotes: 0

Views: 1890

Answers (1)

Atul Chaudhary
Atul Chaudhary

Reputation: 3736

Follow the link I have provided on how to create and use the connection string https://learn.microsoft.com/en-us/ef/core/miscellaneous/connection-strings

And to communicate with the database from Xamarin please do the following

  1. Create .Net Core API project which allows external client to communicate with the backend in ur case it is SQL Server

  2. Create .Net Standard as data access layer where you can use DbContext and all that

  3. Create Xamarin project and use Http Client to communicate with the .Net Core API

Upvotes: 1

Related Questions