ASP.NET MVC Model Generator
This is a simple, time-saving, C# Utility that will generate MVC Models from a database table. I've switched to mainly using Dapper ORM (instead of Entity Frameworks) for my MVC projects to take advantage of the performance gains. This utility helps me save time and avoid the tedious work of generating my models for mapping for Dapper.
This project does use my personal Data Access Layer to interact with the Database. It supports parameter queries, and is very lightweight.
The app contains minimal error handling and assumes your database is online and your Connection String is valid. I'll add error handling when and if time permits.
How to Use
Prerequisites You'll need a well formed SQL Connection String to connect to a database. If you need them, visit Connectionstrings.com for reference.
- Enter your connection string into the field and hit click Connect.
- Select your table name from the dropdown list.
- Enter your project namespace (optional)
- Click Generate.
The text area will contain the generated class and the interface which you can now copy and paste.
Notes The app.config contains the default connectionstring under "SQL". If empty, plug one in and the application will load it up on startup.
Some features are a work in progress and not finalized. I'll update this readme file as features are updated or modified. Things currently in progress which should be updated shortly:
- User Interface to be improved as features are added.
- Dapper CRUD functionality generation is still being developed. Basic code is now available through generated business layer.
- Added basic dynamic parsing of the table (including determining primary key)
- CRUD generation through business layer.
- Split out generated code to tabs.
- Initial Commit.
- Contains the bulk of functional code, with minimal error handling.
- Only tested against Microsoft SQL 2012 but should work with Microsoft SQL 2008+.
In no particular order:
- Generate Views
- Generate Controllers (with CRUD functionality)
- Map SQL table relationships and generate model Lists automatically
- Make Database Server Agnostic
- Export Generated Files as .CS files
- Add command line support
- Switch to Visual Studio Plug-in (or Resharper add-in)
- Generate Web API code
- Add Support for stored procedures
- Allow generation of multiple models simultaneously