How to generate model classes from existing sql server DB - entity-framework

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!

Related

Can't get Blazor project running with Entity Framework

I'm trying to create a simple Blazor client server app using EF, similar to this article.
So I've got a client, server, and common libraries, and this worked fine. But then I added the EF component to the common library, so that I could use real data from my database, instead of toy data from the demo.
I tried making them all Core 3.0, but this doesn't work because Blazor seems to require .NET Standard 2.0. Without that, I get all kinds of errors.
But then the common library can't use EF, because (if I'm reading this right) EF6 isn't supported on Standard 2.0. If I try, I again get tons of errors.
So I'm not sure, but I can't find any scenario that would allow me to share EF objects between client and server--which is a major rationale for Blazor.
Is there some other way to accomplish this?
The shared library should not use or reference EF.
Add EF to the Server project only and make the data available through an API controller.
You should make the common project netstandard and use EF core (not EF 6)

Project Structure for Data Application with ASP.Net Core

I am building an application that hits a database and does some stuff and I want to make sure I am building my solution and project structure correctly. The application will be exposed via WebApi using ASP.Net Core using .Net Framework. I have a class library that I will use to interact with the database (using EF6) and want to make sure I am configuring the startup right to make sure my Controllers will be able to call into the DB though that layer. In the past, all i really had to do was reference the CL and add the connection string to the Web.config. Since now I am using appsettings.json to store my connection string, how do I wire up the DI to make sure all calls to the service layer have that connection string?

Xamarin Native Entity Framework

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

Lightswitch and Entity Framework

I am trying to build a simple db application. I learned EF code first approach and liked it. However I don't want to deal with interface design. Lightswitch seems to be right tool to create my CRUD screens easily. What I understand is I can easily develop my application logic, db structure and test it using lightswitch. However I am not sure about how to use lightswitch with EF code first approach. Can you suggest a way to solve my problem?

Sharepoint hosted CRUD Application? (Entity Framework?)

I am going to create a basic "CRUD" application that will "live" inside Sharepoint 2010. The data will be hosted on a SQL 2008 R2 Server.
Basically, there will be a few "Add" forms, some Queries and some Reporting (SSRS).
Honestly, the application doesn't really even need Sharepoint, but we are trying to get as many of these applications hosted inside Sharepoint as possible. (The application is currently a Microsoft Access application.)
I have experience creating these types of applications (ASP .Net) and have recently been using the Entity Framework. Generally, I design my Data Layer in a seperate Visual Studio Project (using EF) and then extendthe partial classes it creates and/or sometimes create another POCO layer to access the data (depending on how much "business logic" there is).
Anyway, the question I have is:
If I create a (Visual Studio) Solution (I know I have to target .Net 3.5, since because SP doesn't support 4.0 yet), can I use my usual "layered" design and create a seperate project (assembly) that conaints all of my Data Access (Entity Framework) and then have a seperate Project that contains all of the Visual Web Parts (that we design the Data Entry Forms in)? Will this work? Will I be able to call the exposed methods from the (EF) DAL from within the Visual Web Parts (after I deploy my solution to the SP Server)? Will I have to do anything "special" or will both projects get packaged up into a (what is it) "wsp" file and get deployed to SP? (Or, will I have to manually get my DAL Assembly added to the GAC, etc.)
Any examples or tutorials would be a big help to me too.
Also, if you think I am going about this all wrong, I am also interested in knowing how you would create a similar appliation. Is there a better way to do this? (I know I could create a BDC Model and access our SQL data via a Sharepoint List using the External Content Type. Although, for some reason it just seems like that isn't the "right path" for this particular application... I can't put my finger on it, but I am leaning toward just creating a "traditional" ASP .Net app that just uses SharePoint as its "hosting web server".)
Thanks!
Shayne
Can you do it: yes. Should you do it: probably not.
You hit it on the head. You are creating and ASP.NET application, not a SharePoint application.
Anyway, assuming you are going to have to proceed in this manner, here's my advice.
Build the presentation layer (web parts, application pages) using the SharePoint project template and SharePoint project items. This project can reference the assemblies that implement the remaining layers of your application. Visual Studio will then prepare a Solution Package (WSP) that can be used in testing and deployed to production servers.
You should do everything you can to make your application "fit" into SharePoint. It should use the same UI metaphors, respect branding, and so on. Nothing is more jarring to a user then to have pages and web parts that look and behave total different to SharePoint in the middle of a SharePoint site.
If you have the full version of sharepoint you can use Access Services, which will convert your Access application to a web app, just run the wizard
see this video for details: http://channel9.msdn.com/Shows/Access/Microsoft-Access-2010-Demo