-
Notifications
You must be signed in to change notification settings - Fork 15
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
Any chance to extend functionality to be able to supply a connection string and provider and/or startup project? #28
Comments
Yeah well, I've been following the problem right from the start and I just have no clue what's going on. MS seems to be completely ignoring this. AnywayLet me try to better understand what you're trying to do. So, you have a library that contains your entities + Alright, I guess what you're looking for is something like:
This is supposed to be called by your consumers, right? (But this does mean that your consumers will have to know about EF migrations even though you're abstracting EF itself, right?) |
You got it correct. And you're right, unfortunately due to how EF works, I can't abstract 100% of it, but really the only thing my consumers will be doing is running update database command pointing to the API context. But I am abstracting everything else about it hehe. So yes supplying the connection string (and provider like "System.Data.SqlClient" in the current tooling if required) would be helpful. |
Right, can be done. But you'll have to supply your And now that I think about it, there's even a better way. I can read the value from Is the provider really necessary though? I can't seem to find a place where I'd have to specify it. |
I don't know if it's necessary or not, but it currently exists in the current commands: https://coding.abel.nu/2012/03/ef-migrations-command-reference/#Add-Migration When you supply the connection string (not connectionStringName, the full string) in the command, you also must supply the provider since EF can work with multiple types. |
Reviewed the code for it, it's not necessary (at least for now). OK then, I'll see what I can do and I'll let you know here when I update. |
Resolved in 0b09ab5, included in
No need to change your In my tests I found that using localdb won't work when you override the connection string for some reason. So you might have to use SQL Express if you're not already. Note: you can omit the provider's name as the default will be used. For more you can add an Let me know if you have any trouble getting your particular scenario to work. |
You are amazing! Thank you! |
These commands in the EF6 tooling were extremely helpful for my project setup. Basically I have a class library which contains the entity defintions, context, and API for a set of entities. My use case is allowing other programmers to use my API. I've abstracted as much of EF as I can since my API wraps it and they don't care about that. However, this means I am supplying my context connection string at run time like this:
public MyApiDbContext() : base(ApiInitializer.GetConnectionStringName())
and my initializer has them call a command `ApiInitializer.Initialize(connectionStringName) in app startup. This allows my API library to be DB agnostic and anyone wanting to utilize my entities can do so. But this setup doesn't work with your tools. It would work in EF6 tools normally by allowing to specify the startup project as the actual web app and then supplying the connection string name. Or also work by just supplying the full connection string and provider string manually in the migrate command. Any chance you could implement either of those?
Awesome library and thank you, can't believe MS has had no tooling in class libraries for over 9 months still and no ability to run tooling on EF6 in .NET CORE. Too long for very common scenarios.
The text was updated successfully, but these errors were encountered: