It is possible using Entity Framework in xamarin native? I want to create an Entity Framework model from a database (SQL Server). If it is possible how I can do it?
Short Answer: Not Possible.
Reason: You should not expose connection string, queries, authentication on Client Side. Remember that different from a Webapi or MVC app, mobile app is all at client side, it is exposing your database.
Imagine like you are using entity framework on the browser. If they open the app (crackers) they will have credentials, server, they may query your database.
Not by the looks of things at the moment, because Xamarin is dependent on the cross-platform SQLite Engine which is not supported yet by EF. See here: Xamarin.Forms support #4269
Related
I have a website running using ASP & Entity Framework. Now i think to build a Xamarin Application for IOS & Android.
I generate the model classes from Db (used Code first from db ADO).
Now I'm wondering if i can generate the classes in Xamarin app as i did in my ASP App? Or i should do other methods to generate / write the classes ?
And one more question: Does the connection string in Xamarin same as ASP?
I did a little search about this, but i did not get a clear answer to make me think how i should start!
I have a project with a web api, a web app and Xamarin Apps. They all should use the same data model stored in a AspNetCore Library. I want to use EF Core for the database and I have a Db Managing project (also a AspNetCore Library) referencing EF Core containg the context and setup. The web api is the only project referencing this Db Managing project, because it handles all the database access. All other apps are contacting the web api for data interaction.
My problem: I want to use AspNetCore.Identity for my user management, but the Xamarin Apps cannot reference the data model, when its using AspNetCore.Identity. How can I solve this?
Your Xamarin code should be totally decoupled from server business logic and data access. Why would you reference AspNet Identity from Xamarin? Those are two completely different layers.
Your server Web API has to expose REST methods to handle authentication/authorization and other stuff so a client can consume them (web client, mobile client, desktop client, whatever).
Xamarin should consume those remote methods with a REST client, in the same fashion a javascript client would.
I understand from your question that you want to reuse business objects / models in your xamarin project just because they are written in C#. But if those objects have dependencies on asp.net identity, you can´t.
In that case you should map your business objects (BO) to data transfer objects (DTO) that web API will use to communicate with clients.
DTO´s are completely agnostic from any data access layer and should be simple POCO´s. They are meant to be serialized/deserialized to/from json/xml.
On the other hand, you don´t want to serialize user models "as is" through a web api because that implies sending sensitive data over the internet like user hashed passwords, etc. Your DTO´s should just have the fields needed in your client, and the mapping will do the rest.
We are currently looking at converting from WCF Data Services to WebApi with Odata. Our entity model is defined using an entity framework defined as an edmx. Im struggling to get the edmx working with WebApi OData due to relationships and complex properties.
I'm just wondering whether someone has successfully implemented webAPI with odata on a bigger sized edmx (that has relationships as well)? Any advice would be great.
You may try using RESTier -- a .Net framework built upon Web API OData. There are several things you may need to pay attention:
RESTier has an EF provider which is quite similar with WCF data services. So it should work wiht the edmx model with little tweak.
RESTier is not a "competitor" for Web API OData, it's built upon Web API OData and can fallback to Web API OData.
RESTier currently is a preview version, but it has good support for the common features used of OData service.
If you tried out and find it cannot work, you can create an issues on https://github.com/odata/restier/issues with more detailed information, if you successfully make it work, it will be great you share your experience.
I have to develop a desktop windows application in C#.Net 4.0 that will run in three different databases ie. MS Access 2007 onwards, Oracle 11G, and SQL Server 2008. Now I want to use Entity Framework in my application. Is this a best choice to use EF for my application ?
If yes, then how can I use entity framework for Access database?
Thanks in Advance.
You can use the EF with Microsoft Access using an Entity Framework provider for Microsoft Access.
You can find an EF provider for Access
https://github.com/bubibubi/JetEntityFrameworkProvider
See this answer. Ask yourself why you need Access, could you use SQL Express instead? If you absolutely need Access then it would seem EF is not the right choice in this instance.
Putting Access to one side for the moment, it's perfectly possible to change data providers with EF (particularly code-first) as EF abstracts a lot of the database goo away from your code; depending on the database design it could be as simple as changing the connection string dynamically. The practical implications of this really do depend on your database design and the nature and complexity of the application you are building. See this question for example, here's another example.
We use Dapper as our ORM with repositories when working with MS Access. It's fantastic.
We're investigating the iPhone Enterprise Developer Program as a way to develop and distribute in-house apps. Since our backends are all Windows, SQL server and Oracle databases, we have to find out a way to make our data available for the coming in-house apps.
As far as I know that Core Data is mainly based on SQLite as persistent store. I am not sure if there are any APIs available in iPhone SDK for SQL server or Oracle database? Another possibility, or very attractive strategy, is to build our own web-based REST services as CRUD gateway to our databases.
Personally, I prefer to integrate in-house apps with our ASP.NET based web services. I am not sure if this is possible. Are there any examples or documentations about this strategy?
an interesting option is to expose your data from your server using asp.net OData then use this project to generate a client in objective-C to consume your OData service.
As far as I am aware there are no approved API's to access a server based database. The way we do it in our organisation is pretty much the way you are suggesting. In some instances we are using SOAP but typically we just use a custom JSON or XML web service to access the data.
With regards to ASP.NET are you talking about making native iPhone Apps with ASP.NET or getting a native iPhone App to talk to an ASP.NET web service? If its the first then have a look at monotouch (don't know much about it), if its the later then this shouldn't cause issues. Just use NSURLConnection and deal with the resource structure on the App (be it JSON or XML).
The added advantage of using a web service rather than a straight database connection is that you get encryption for free using https.
Hope that helps
There's a product called SUP (Sybase Unwired Platform), it provides a framework to handle access to databases but has the advantage that there doesn't need to be an online access all the time, it stores persistent data locally and then can sync up with the host database using messaging.