Code Monkey home page Code Monkey logo

ef-enum-to-lookup's Introduction

Entity Framework 6.1 Enum Lookup Table Generator

About

Creates lookup tables and foreign key constraints based on the enums used in your model.

This makes up for a feature that's missing in Entity Framework 6.1.

Usage

Run EnumToLookup.Apply() from your Seed method in either your database initializer or your EF Migrations.

Use the properties exposed to control behaviour.

It is safe to run repeatedly (Idempotent), and will ensure enum values are kept in line with your current code if run regularly (e.g. in the migration seed method).

For example usage see ExampleUsage/EnumExample.cs, which can be run in the test project project "ExampleUsage" if you want to see it in action.

var enumToLookup = new EnumToLookup();
enumToLookup.NameFieldLength = 42; // optional, example of how to override default values
enumToLookup.Apply(context);

Creating sql scripts

If you can't point this library at your production database and let it make changes then you may need to generate sql in advance. As of v1.7.0 you can do this by running

var migrationSql = enumToLookup.GenerateMigrationSql(context);

instead of Apply() (or as well if you like).

Contributing

Feedback, bug reports, pull requests all welcome, head over to github.

Repository

Files stored as LF, converted on checkout to windows, configure locally with

git config core.autocrlf true

I've looked into the .gitattributes approach to this and it doesn't seem to have the desired effect on a windows checkout.

Further reading

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.