Generally, in Telerik OpenAccess ORM, when you map associations and update your database the way you do, the foreign key constraints will not be created. In order to generate the script for the constraints, you should override the CreateModel() method in your FluentMetadataSource class.
The best practice in this case is:
- Add a new class
to your project
- Name it EntitesModelFluentMetadataSource.partial.cs
it and make sure you have "public partial class
" before the name of the class, it will be a partial class for your FluentMetadataSource
- Inside the class, you have to override the default value we are setting to the NullForeignKey property, which is preventing the creation of constraints. In order to do that, paste
MetadataContainer container =
Note that if you have built your model using Model First
scenario you will have to do additional configuration of the association in the generated code (check here
I also suggest you to check the best practice for using fluent code generation described here
the Telerik team
Telerik OpenAccess ORM Meets ASP.NET Web API. Read more.