nsabiyera / Oak

Frictionless development for ASP.NET MVC single page web apps. Prototypical and dynamic capabilities brought to C#.
http://amirrajan.github.com/Oak
MIT License
6 stars 7 forks source link

Allow 'not null' Foreign Keys in Seed #12

Closed kradcliffe closed 12 years ago

kradcliffe commented 12 years ago

Currently, "Nullable" is thrown away when creating Foreign Keys in Seed. In my example below, the Nullable flag for my foreign key is thrown away within Seed.NullDefinition

I want to be able to make my foreign key 'not null' But, maybe there was a good reason for initially removing the null/not null info from foreign keys?

My example:

        public string CreateRolesTable()
        {
            return Seed.CreateTable("Roles", new dynamic[]
            {
                Seed.Id(),
                new { Name = "nvarchar(100)", Nullable = false },
            });
        }

        public string CreateUsersTable()
        {
            return Seed.CreateTable("Users", new dynamic[]
            {
                Seed.Id(),
                new { Name = "nvarchar(100)", Nullable = false },
                new { Email = "nvarchar(100)", Nullable = false },
                new { RoleId = "int", ForeignKey = "Roles(Id)", Nullable = false },
            });
        }
kradcliffe commented 12 years ago

For now, in my own code, I just commented out this line within Seed.NullDefinition

if (columnDefinition.IsForeignKeyColumn()) nullDefinition = "";
amirrajan commented 12 years ago

Noted. Should be able to look at it this weekend. Thoughts on Oak so far?

kradcliffe commented 12 years ago

Amir,

Seems awesome to get up and running quickly!!! Using the debugger was a little difficult at first, but now I have the hang of it (With full understanding that generally TDD/BDD approach is best, avoiding the debugger)

One thing that EF simultaneously somehow sucks at and is good at is Entity relationships. Interested to see how far I can get in Oak using tables with relationships.

I really like writing the schema the Oak way though! EF makes me want to scream, so I am looking forward to slick, simple schemas using Oak too.

Thanks for writing Oak! Warmest Regards, Kevin

On Thu, Jul 12, 2012 at 9:45 PM, Amir Rajan < reply@reply.github.com

wrote:

Noted. Should be able to look at it this weekend. Thoughts on Oak so far?


Reply to this email directly or view it on GitHub: https://github.com/amirrajan/Oak/issues/12#issuecomment-6934038

amirrajan commented 12 years ago

I think you'll be very happy with how Oak handles entity relations, feel free to contact me any time at ar@amirrajan.net (and of course refer to the wiki): https://github.com/amirrajan/Oak/wiki/Adding-associations-using-Oak.DynamicModel

amirrajan commented 12 years ago

Here is the fix, I'll push oak related packages and warmup templates soon by Sunday.

https://github.com/amirrajan/Oak/blob/master/Oak.Tests/describe_Seed/when_creating_table.cs#L236