Quantcast
Channel: ADO.NET, Entity Framework, LINQ to SQL, NHibernate
Viewing all articles
Browse latest Browse all 1698

Linq changed variable name-prevents Insert

$
0
0

I have a table that has a foreign key category.id

When I dragged the table onto the dbml diagram the field name has been changed to category_id

I have also dragged an INSERT stored procedure onto the dbml diagram

intellisense is happy with category_id in the block below

Using dbContext As DataClassesDataContext = New DataClassesDataContext()
                Dim newTemplate As template = New template With {
                    .name = txtNewTemp.Text,
                    .category_id = ddlCategory.SelectedValue,
                    .text = "blank for now"
                }
                dbContext.templates.InsertOnSubmit(newTemplate)
                dbContext.SubmitChanges()
            End Using

But in execution I get an error that 

Cannot insert the value NULL into column 'category.id

Please advise




Viewing all articles
Browse latest Browse all 1698

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>