This project is read-only.


During DbDatabaseExist call, the AssociationSet do not have correct details; if Fluent APIs or Data Annotations are used to modify the Table Name participating in the ForeignKey relationship. The AssociationSet still preserves the old name defined in the


We are third party EF provider and we are seeing an issue with CreateIfNotExist. With this call our provider generates a query to look for database objects like tables, keys e.t.c for the Context.
And if in model table name is modified using dataannotations or fluent api we see an issue in foreign key names.

Foreign Key name is dependent on table name and foreign key columns. In DbDatabaseExists method we generate a query to identify existence of database objects for the context. And inside the same method for ForeignKey names we refer AssociationSet of StoreItemCollection that we receive in DbDatabaseExists. But the problem is we are not receiving AssociationSet with correct details, it shows the table name same as class name instead of name which was specified in data annotation or fluent api. This results in wrong Foreign Key name to be searched. But create database object queries are getting generated correctly.

And as there is difference in foreign key names that were used while creating and verifying, provider gets mislead that database is not present in backend. And thus, tries to create database objects. And fails with Table or View already exists.

So, our issue will get resolved if AssociationSet is correctly updated with data annotation or fluent api table names.
Closed Mar 27 at 8:55 PM by ajcvickers
EF Team Triage: Thanks for reporting an issue on Entity Framework 6.x. This project is now maintained on GitHub ( Please file your issue on the GitHub issue tracker. We will no longer be monitoring this issue tracker for comments, so please do not reply here.