Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding annotations to DTO triggers code first entity framework migration #195

Open
mprigge opened this issue Jan 16, 2019 · 0 comments
Open

Comments

@mprigge
Copy link

mprigge commented Jan 16, 2019

I'm running into a very strange problem I'm having very little luck explaining, so I thought I might throw it out here in case you can think of any reason why this might occur.

I have a core library that implements a code first EF6 context which is then referenced by two web projects which utilize the context. Another shared library defines some common DTOs which are used by some external client libraries -- this library is referenced by the core and web projects as well but references very little otherwise. None of these DTOs are EF entities.

I am experimenting with adding Expressive Annotations to this shared library -- to apply the same validation on these DTOs. To do this, I referenced the ExpressiveAnnotations.dll nuget in the shared library which then allows me to decorate properties of the DTOs as necessary.

However - the super weird thing is that doing this causes entity framework to believe that the data model has changed and to prompt me to create a code first migration. To be clear, the DTOs I'm decorating are in no way involved in the context nor referenced as nav properties or anything else. I have no idea how simply doing this is causing EF to scoop them up and believe that it needs to do anything. More confusing, generating a migration produces empty Up/Down migrations which doesn't even give me a hint of what it thinks the problem is.

So yeah - this is a "flush the toilet and the TV shuts off" sorta situation, but I figured I'd ask here in case this seems familiar in any way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant