I have a requirement in which in order to make an application extensible and reusable, I have to create a provision through which a user would be able to provide a business object structure (the fields, their types, etc.) through an XML file and using that structure the UI (i.e. the controls and the complete page), the data updation methods (CRUD) and the database (i.e. the tables and the SPs) can be dynamically generated automatically in order to cater to the business object.
I've 'only' heard about Entity framework, LINQ, etc. but do not know if they'd be any helpful in achieving what I wish for.
Any suggestions or guidance on how to approach towards this design goal would be highly appreciated.
Thanks a ton!
You may want to take a look at ASP.NET Dynamic Data. It still requires you to provide it an Entity Framework model, but you can dynamically generate the model using the EdmGen.exe tool.
Here is some info about each... Follow the links more more detail.
ASP.NET Dynamic Data
ASP.NET Dynamic Data provides a framework that enables you to quickly build a functional data-driven application, based on a LINQ to SQL or Entity Framework data model. It also adds great flexibility and functionality to the DetailsView, FormView, GridView, and ListView controls in the form of smart validation and the ability to easily change the display of these controls using templates.
EdmGen.exe
EdmGen.exe is a command-line tool used for working with Entity Framework model and mapping files. You can use the EdmGen.exe tool to do the following:
Connect to a data source by using a data source–specific .NET Framework data provider, and generate the conceptual model (.csdl), storage model (.ssdl), and mapping (.msl) files that are used by the Entity Framework . For more information, see How to: Use EdmGen.exe to Generate the Model and Mapping Files.
Validate an existing model. For more information, see How to: Use EdmGen.exe to Validate Model and Mapping Files.
Generate a C# or Visual Basic code file that contains the object classes generated from a conceptual model (.csdl) file. For more information, see How to: Use EdmGen.exe to Generate Object-Layer Code.
Generate a C# or Visual Basic code file that contains the pre-generated views for an existing model. For more information, How to: Pre-Generate Views to Improve Query Performance.
Check out lightswitch:
http://www.microsoft.com/visualstudio/en-us/lightswitch
commercial product: Enterprise Elements Repository
Related
I want to create a platform that can read an XML or JSON configuration of entity names, their properties, and relationships and do basic CRUD operations on these entities as a starting point.
This means there will be no C# class definitions for these entities.
I would like to use a SQL Server database for this, however I believe it would be much easier to use something like a Graph or NoSql database since there is no predefined structure to create an ERD.
I would also like to use C#, Entity Framework, and JSON.NET to work with these dynamic entities and process business logic on them.
Another way of explaining it is the following:
Through a UI I would like someone to be able to do the following:
Create an Entity called Book.
A Book has the following properties: Title, Description, Author (one-to-one relationship w/ Author)
Create an Entity called Author.
An Author has the following properties: FirstName, LastName
What is a platform like this called and can someone lead me in the right direction?
What is a platform like this called and can someone lead me in the right direction?
Those applications are called Database Administration. Some examples are SQL Management Studio and PHPMyAdmin.
I want to create a platform that can read an XML or JSON configuration of entity names, their properties, and relationships and do basic CRUD operations on these entities as a starting point.
Why do you want to do it? We already have many application which has decades of developement efforts.
A quick search showed me a tutorial how to create one using ADO.NET. I haven't taken a closer look to it, but you can be sure, such an application is not as simple as following a tutorial.
I would also like to use C#, Entity Framework, and JSON.NET to work with these dynamic entities and process business logic on them.
Remember: Entity Framework is an ORM (Object-relational mapping tool). It's job is to high level map between your existing database and your application. You do not want to map your application code to a database, you want to administrate that database.
Therefore, EF is the wrong tool for the job. I think ADO.NET is the best you can do. You want to create a low level database application, so you need to use a low level tool.
That said, probably you want to just create some user defined content types? Then we are talking about a CMS. Probably you find some ideas in the Orchard Content Management System.
I've been searching all over trying to find a reasonable and working solution to this.
I've created a new Database using EF6.0 (VS 2013) using a Model First approach. This model was created in the WPF application that will utilize the database. I have been unable to successfully implement any type of data validation (I've done data annotations in ASP and EF, metadata classes etc), however, I've been unable to get my meta data classes to be utilized.
Does anyone have any straightforward write-up/article/blog/etc that has a firm and VALID example of how to use EF6 Data Validations to drive notifications to the UI in a WPF application? Any assistance would helpful, or perhaps, better advice on data validation. I could easily write custom validation logic to check the entity before attempting to persist to the database, but this seems counter intuitive to the idea of the Entity Framework and its built in validation attributes.
Are your mapping files created using Fluent API or data annotations?
Maybe you can implement IValidatbleObject interface, or you may use the FluentValid library.
Check this answer How do I use IValidatableObject?.
Hope that helps.
I will be using Solr search server with my ASP.NET 4.5 application. I've already installed SOLR on my Windows 8 laptop computer. According to SolrNet this documentation, I need to use specific attributes on my POCOs.
The thing is that I am using Entity Framework and my classes are auto generated. Is there an option to assign those type of Solr attributed and also make sure that they are presistant and won't be erased if your suggested solution is based on editing the template (.tt) file.
I want to use Entity Framework, but if it is not possible, I will just copy the pocos and create the classes myself with those Attributes. But I prefer searching for a solution that will allow me to use solrnet with Entity Framework. Thanks.
I would suggest that you create separate classes that map to your Solr Index schema, as typically the structure of your EF classes and your index schema will not be identical. This way you have a clean separation between your persistence classes (those auto-generated by EF) and your index mapping classes and can control how the mapping between the two occurs. I recommend the use of AutoMapper to assist with translating your objects from EF to Solr and back again as needed.
I'm trying to build a web application that let the administrator talk to the database through C# and add new tables and columns to fit his requirements (sort of a very simple database studio) but I'm not trying to just create some spaghetti application.
So I'm trying to figure out how to let those things dynamically (automatically) when he creates a table and use the table to build them :
1- The business objects or entities (the classes, it's objects and properties).
2- The Data access layer (some simple methods that connects to the database and add, update, delete retrieve items (objects)).
Is this possible ? any pointers on how to achieve it ?
EDIT
just opened your link!! .. it's talking about the data bound controls and stuff! .. my question is way more advanced than that!.
when you build an N-Layered application you start with the database schema and implementation and it's easy to do programtically then you start building the DAL classes which (add, edit, etc in other words the CRUD operations) in and form this database
what I want to do is to allow the web administrator to choose add the new table through my application and then -dynamically- the application would take the tables names and columns as parameters and create new classes and define within them the CRUD methods that will implement the SQL CRUD operations
then it would also create dynamically the classes and define within them the variables, properties and methods to call and use the DAL methods .. all this based on the table, column names
NOTE : All this happens on the run-time!
You might want to look into ASP.Net Dynamic Data. It's a RAD tool which very easily gives you CRUD functionality for your entities and more. Check it out.
Sometime back I had also asked similar question on SO. I got only one reply.
Today I was digging some information on MSDN and as I had guessed it, MS CRM entity model works based on metadata. So basically whatever a CRM developer is working against is just metadata, they are not real objects as such. Following is the MSDN link.
Extend MS CRM Metadata and here is the MS CRM 4.0 SDK.
I hope this should get you started.
Update: Recently hit upon Visual Studio LightSwitch. I think this is what we wanted to build. A UI which will pick up table information from DB and then create all CRUD screens. VS LightSwitch is in its Beta1 and has quite a lot of potential. Should be a nice starting point.
First, any man trying to create MS Access is doomed to recreate MS Access. Badly.
You are better off using ASP.NET Dynamic Data (as suggested) or ASP.NET MVC Scaffolding. But runtime-generated playforms that actually make decent applications are really pipe dreams. You will need developer time to do anything complex. Or well.
What you are asking is non-sense. Why? Because the idea behind BLL and n-tier is that you know your data model well, and can create a static class model to represent your data model.
If your data model is dynamic, and changing, then you cannot create a static BLL (which is what a BLL is). What you will have to do dynamically build your queries at run-time. This is not something that any of the traditional methods are designed to handle, so you must do everything yourself.
While it's possible to dynamically generate classes at run-time, this is probably not the approach you want to take, because even if you manage to make your BLL adapt to your dynamic database.. the code that calls the BLL will not know anything about it, thus it will never get called.
This is not a problem you will solve overnight, or by copying any existing solution. You will have to design it from scratch, using low level ADO calls rather than relying on ORM's or any automation.
I have an application where I create database's dynamically in a SQL Server using Server Management Objects through my application.
I want to use the Entity Framework to access this database when it has been created, is this possible? As I can not generate Entity classes from a database in VS. I do have the structure of the database of course.
So is it possible to create the Entity classes manually and is that a do-able task?
Yes, it's completely possible. You can even manipulate the generated code if you want.
What you might want to take a look is the EDMX XML specification.
In that file you specify the underlying database, views, functions, procedures and the like, as well as the desired objects. Take a look at MSDN in order to have more information.
Paulo is right for EF 1 (+1). For EF 4, I'd suggest using code-only modeling instead.