Click here to Skip to main content
15,903,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
Im trying to get Asp.Net Identity to work with Entity Framework.

But im not getting that far.
Every time I call
C#
FootModelEntities aa = new FootModelEntities();

And then I check the Connection and noticed
XML
ServerVersion = '(((System.Data.Entity.DbContext)(aa)).Database.Connection).ServerVersion' threw an exception of type 'System.InvalidOperationException'


Why is that happening?
I have been google`ing and cant find any help.
Im using Entity framework 6, SQL Server 2012

Thanks
Jakob
Posted
Comments
johannesnestler 2-Jul-14 14:54pm    
does the Connection not work, or is this just what you see while debugging?
jakobvjensen 2-Jul-14 15:04pm    
The connection not working..
But think maybe i know what the problem is.. I started the project as model-first, then i added some tables and updated the designer from database. And i think its where the problem started
johannesnestler 3-Jul-14 13:15pm    
hmmm - if you can synchronize the changes between your database and model it should work again - no matter how you manage that. OT: I like to do the mapping "manually" in code - much less headaches in the long run, and I don't want to mess arround with T4's...
jakobvjensen 4-Jul-14 0:33am    
I manage to found out what the problem was.. It was because i did'nt made my controller action async, and had the call await.. So now its working..
I would also like to manage relationships in code. But after i looked at the modelbuilder in the OnModelCreating im worried that i miss something if i write that myself.. I have also seeing a lot of examples on the internet that are very different from each other and also very different than the code that EF auto generate
johannesnestler 4-Jul-14 4:13am    
Nice to hear you solved your problem. I see the most benefit in doing the mapping in code when it comes to relations - in some cases (I have to work with DB-First...) the automatic mapping is impossible and you have to code it anyway. But you are right it takes sometime to learn it - but the fluent syntax is very cool and maintainable (and in doubt just generate it, and have a look how the generated mapping code works). But it depends on the type of projects you work on if the manual approach is the right one. If database is heavily normalized and "big", configuration (and maintaining it) is a nightmare, you end up with generated mapping, edited model configurations, coded mappings all together. With code I feel I have the total control and nothing "magically" changes :-)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900