I am new to Silverlight and am developing an ASP.NET web application that requires a Silverlight project to record webcam audio/video streams.
The solution consists of a library project containing business entities such as [User], [BillingInfo], etc., and an ASP .NET Web Application.
Since Silverlight does not support EF, how can I use the strongly-typed entity objects from within Silverlight? I do not need access to the Context object but will require access to Entity classes.
I use Code First so have to mark Entities with Annotations which Silverlight will not recognize since the DataAnnotations assembly is not referencable. Switching to model-first is also an option (albeit less preferable) if required.
Has anyone dealt with a similar scenario? What is the best way to get strongly-typed entities in Silverlight. Any articles or references would help as well. Thank you.
Technologies (upgrade is an option if required):
ASP .NET Web Application (.NET 4)
Entity Framework 5
Silverlight 5
I would recomend giving WCF RIA Services a try. This will simplify the data access for your application and provide you with strongly typed entities on the Silverlight client side.
Silverlight works very well with entity framework!
You could directly consume your entity through webservices as describe in this blog: http://geekswithblogs.net/berthin/archive/2011/05/29/ado_net_entityframework_from_silverlight.aspx
Or as Dave suggest, you could combine RIA services and Entity Framework, so you could use annotation http://blogs.msdn.com/b/brada/archive/2010/03/15/silverlight-4-ria-services-ready-for-business-exposing-data-from-entity-framework.aspx
The combination of Silverlight and Entity Framework create a really powerfull ready to use business logic.
Related
I am building a new ASP.NET Core 5 MVC app. I want to use clean architecture as outlined in Microsoft's web app architecture ebook.
I am also studying eShopOnWeb sample application available here :
https://github.com/dotnet-architecture/eShopOnWeb
What I understand from the ebook and sample app is - EF Core entity classes (say Customer, Product, Order) will go inside ApplicationCore project's Entities folder. The DbContext will be in Infrastructure project.
My confusion is: is it alright to add data annotation schema attributes such as [Table], [DatabaseGenerated], and [Key] on these entity classes inside ApplicationCore project? If not, where should I add these data annotations?
Any advice in this regards is highly appreciated.
Thank you.
In the example of eShopOnWeb they separate Entities and configuration models. So, that means to have clean architecture you don't need annotations directly in these Entities.
You can use FluentAPI, as they used as well in the Infrastructure/Data/Config directory.
So, if you have a separate project for DataContext that is the best location for describing your entities with FluentAPI in this case.
More information about FluentAPI:
https://learn.microsoft.com/en-us/ef/ef6/modeling/code-first/fluent/types-and-properties
Does the entity framework provides an API for .net (c#) to generate models from an existing database? I don't want to use EdmGen.exe, because a direct integration would be nice.
Maybe even the code which is used by the EdmGen.exe provides some information, because they also have to use some API functionality.
This is needed, because i want to compile the models dynamicaly with roslyn at runtime, which is currently working pretty well with some demo models.
Thank you.
I am pretty new to ASP MVC. All the coding I have done to this day is based upon the three tier structure in ASP Webforms. However, I have been able to relate the MVC project structure with that of the ASP Webforms project structure. Like, I can pretty well understand how the controller and the views work, but there is a problem regarding the models.
My first question would be, is it necessary that we must follow the Entity Framework data model in MVC. I am pretty used to in ADO.NET and have been unable to understand how the entity framework works. Likewise, can we use the same three tier project structure in ASP MVC4 for importing data from database completely neglecting the "MODEL".
Please, have your say in this. It is really getting confusing trying to implement the same three tier structure in MVC Projects.
Thank You!!!
This is an extensive topic, and i would like you to point you to a very nice tutorial that i am currently learning from !
Getting Started with Entity Framework 4.0 Database First and ASP.NET 4 Web Forms
You can use any pattern you like. MVC doesn't impose any restriction and it is not necessary to use Entity Framework or other ORM so if you are good at ADO you can use ADO.
There are various MVC open source project available on codeplex, you can refer those projects.
Tutorial and Project links:-
Getting Started with EF using MVC
Building an ASP.NET MVC4 Application with EF and Web API
Prodinner MVC Project
As already mentioned MVC does not impose usage of any ORM. It is upon you how you build your models and supply data to it.
As with any new thing take some time to learn it before embarking upon a serious project.
Check out the official MVC site for examples or Pluralsight for tutorials to get a deeper understanding of what ASP.NET MVC entails.
For EF, check out this site
ORM like EF is used by many because it makes our tasks easier.
Although using Microsoft ASP.NET MVC technology without models is certainly possible , you will lose out on some of the MVC features like Validation through Data Annotations etc.(But then it would not really be MVC, is it?)
At my work place,we still use the three tier architecture. One contains all models,another our business logic and the last our views.We still use ADO.NET for bulk uploads and inserts as we found it is quite time consuming through an ORM.
So mix and match and march on!
I have worked with products of Telerik about two week,and in my opinion the Entity Framework is better than the Open Access(ORM), But i wonder that other Products of Telerik(EXP:GridView or ....) hasn't any problem with Entity Framework? I want to start a Project with Entity Framework and Telerik's Controls
You shouldn't run into any problems. Entity Framework and the Telerik Tools are compatible with one another, in fact I have used EF and Telerik together in a number of projects.
We use the EntityFramework in conjunction with Telerik's controls extensively, and have not had any issues or problems. Telerik's controls seem to always behave as expected when binding to individual objects or lists.
Good luck!
To take the classical 3 tier approach...
Are you asking if your data access layer (i.e. EF) is compatible with your UI (i.e. Telerik controls)?
The answer is kind of up to you as you should provide the middle layer (i.e. the business/service layer).
If you are finding direct dependencies between the two then I would advise looking at the architecture of the application. They shouldn't be connected directly.
Given that directly exposing linq to sql or entity framework classes over web services is a bad idea, how should I expose the data over a web service such as WCF?
It seems like I would have to create a parallel set of classes for the web service, and then marshal the data into those, which doesn't seem very elegant.
The web services will be custom, so something like RIA is not very useful in this case.
You can use the support for POCO (Plain Old CLR Objects) in EF 4 to expose the entity model as simple objects. The designer supports converting entity data model into POCO objects.
Specifically for WCF service scenario, you could also use the self tracking entities T4 template available in EF 4 when you try to add new item to the project.
I hope following link will be helpful to you
http://blogs.msdn.com/b/efdesign/archive/2010/03/10/poco-template-code-generation-options.aspx
http://blogs.msdn.com/b/adonet/archive/2010/01/25/walkthrough-poco-template-for-the-entity-framework.aspx
Generate POCO classes in different project to the project with Entity Framework model
Have you seen OData and WCF Data Services? Here is a great talk by ScottHa: http://www.hanselman.com/blog/ODataBasicsAtTheAZGroupsDayOfNETWithScottGu.aspx
OData, through WCF Data Services, works seamlessly with EF 4.